Skip to content

Commit 7c97af9

Browse files
authored
Merge pull request #87 from messerli-informatik-ag/gardening
2 parents 5515ce9 + 603adbc commit 7c97af9

File tree

7 files changed

+167
-182
lines changed

7 files changed

+167
-182
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-dotnet@v1
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-dotnet@v3
1818
- name: Install dependencies
1919
run: dotnet restore
2020
- name: Build
2121
run: dotnet build --configuration Release --no-restore
2222
- name: Pack
2323
run: dotnet pack CodeStyle/CodeStyle.csproj --configuration Release --no-restore --output nupkg
2424
- name: Test that files are importable by MSBuild
25-
run: ruby ./scripts/test_files_are_importable_by_msbuild.rb
25+
run: dotnet fsi scripts/test-files-are-importable-by-msbuild.fsx
2626
- name: Show NuGet package content
2727
run: unzip -l nupkg/*.nupkg

.github/workflows/docs.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,33 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v1
16+
- uses: actions/checkout@v3
1717
- name: Setup mdBook
1818
uses: peaceiris/actions-mdbook@v1
1919
with:
2020
mdbook-version: '0.4.0'
2121
- name: Build Documentation
2222
run: mdbook build
2323
working-directory: ./documentation
24-
- name: Deploy
25-
uses: peaceiris/actions-gh-pages@v3
26-
if: success() && github.ref == 'refs/heads/main'
24+
- name: Upload GitHub Pages Artifact
25+
uses: actions/upload-pages-artifact@v1
2726
with:
28-
github_token: ${{secrets.GITHUB_TOKEN}}
29-
publish_dir: ./documentation/book
30-
commit_message: ${{github.event.head_commit.message}}
27+
path: ./documentation/book
28+
29+
deploy_pages:
30+
needs: build
31+
if: github.ref_name == 'main'
32+
33+
permissions:
34+
pages: write
35+
id-token: write
36+
37+
environment:
38+
name: github-pages
39+
url: ${{ steps.deployment.outputs.page_url }}
40+
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Deploy to GitHub Pages
44+
id: deployment
45+
uses: actions/deploy-pages@v2

changelog.md

Lines changed: 95 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
11
# Changelog
22

3-
## 1.0.0-alpha.1
4-
Initial release
5-
6-
## 1.0.0
7-
- Add support for netstandard2.0.
8-
- Add support for projects that target multiple frameworks.
9-
10-
## 1.0.1
11-
- Hide stylecop.json in Visual Studio.
3+
## 2.2.0
4+
* File scoped namespaces are now enforced. (#81)
5+
* Enable warning for unused usings. (#81)
6+
* `SA1305: FieldNamesMustNotUseHungarianNotation` has been disabled. (#82)
7+
* Use warning instead of error level for spacing rules. (#83)
8+
* Update IDisposableAnalyzers to 4.0.2. Excerpt from [IDisposableAnalyzers Changelog]:
9+
> #### 4.0.2
10+
> * BUGFIX: IDISP007 when disposing static member in static context
11+
> #### 4.0.1
12+
> * BUGFIX: IDISP007 false warning when using Rx
13+
> * BUGFIX: IDISP016 false warning when foreach
14+
> * BUGFIX: Handle leaveOpen when AsyncDisposable
15+
> * BUGIX: Handle top level statements.
16+
> #### 4.0.0
17+
> * BREAKING: For VS2022+ now.
18+
> * BUGFIX: AD0001 -> Could not load file or assembly
1219
13-
## 1.1.0
14-
- Update IDisposableAnalyzers from 3.2.0 to 3.3.2. Excerpt from [IDisposableAnalyzers Changelog]:
15-
> #### 3.3.0
16-
> - FEATURE: Initial support for AsyncDisposable
20+
## 2.1.3
21+
* Update StyleCop.Analyzers to 1.2.0-beta.435 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.376...1.2.0-beta.435))
22+
* Most notably this version fixes false positives of `SA1516: Elements should be separated by blank line` in files with top-level statements.
1723

18-
## 1.2.0
19-
- Disable SA1412 (StoreFilesAsUtf). This means that BOMs are no longer required in C# files.
20-
- Update IDisposableAnalyzers from 3.3.2 to 3.3.8:
21-
- Update StyleCop.Analyzers from 1.2.0-beta.113 to 1.2.0-beta.164 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.113...1.2.0-beta.164)).
22-
- Enable `GenerateDocumentationFile` by default. This had to be turned on manually in each project before,
23-
as it is required by our StyleCop configuration.
24+
## 2.1.2
25+
* Update StyleCop.Analyzers to 1.2.0-beta.376 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.354...1.2.0-beta.376))
2426

25-
## 1.2.1
26-
- Update StyleCop.Analyzers to 1.2.0-beta.205. ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.164...1.2.0-beta.205))
27-
- Update IDisposableAnalyzers to 3.4.1. Excerpt from [IDisposableAnalyzers Changelog]:
28-
> #### 3.4.1
29-
> * Publish with binaries.
30-
> #### 3.4.0
31-
> * FEATURE: Handle DisposableMixins.DisposeWith
32-
> * BUGFIX: IDISP025 when abstract dispose method.
33-
> * BUGFIX: IDISP006 when explicit implementation.
27+
## 2.1.1
28+
* Relaxed rules:
29+
* [SA1119](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md) (StatementMustNotUseUnnecessaryParenthesis) is now disabled.
3430

35-
## 2.0.0-rc.1
36-
* Breaking: Treat all nullability warnings as errors.
37-
* Lints involving single line comments have been reduced to warnings to make temporary code commenting easier.
38-
* The hungarian notation rule has been relaxed to allow `js` and `db` since those two are common "false positives".
31+
* Update IDisposableAnalyzers to 3.4.15. Excerpt from [IDisposableAnalyzers Changelog]:
32+
> #### 3.4.15
33+
> * BUGFIX: IDISP005 with ServiceDescriptor
34+
> * BUGFIX: IDISP004 when DisposeWith
35+
> #### 3.4.14
36+
> * BUGFIX: IDISP005 should not warn in Assert.Throws.
37+
> * BUGFIX: Handle function pointer.
38+
> #### 3.4.13
39+
> * BUGFIX: Specialcase Gu.Reactive extension methods.
40+
* Update StyleCop.Analyzers to 1.2.0-beta.354 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.333...1.2.0-beta.354))
3941

40-
## 2.0.0-rc.2
41-
- Update StyleCop.Analyzers to 1.2.0-beta.261. ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.205...1.2.0-beta.261))
42+
## 2.1.0
43+
* Warn when interface method has `public` accessibility modifier (`MESSERLI001`)
4244

43-
## 2.0.0-rc.3
44-
- Update StyleCop.Analyzers to 1.2.0-beta.312 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.261...1.2.0-beta.312))
45-
- Fix compilation error when building an F# project.
45+
## 2.0.1
46+
* Update IDisposableAnalyzers to 3.4.13. Excerpt from [IDisposableAnalyzers Changelog]:
47+
> #### 3.4.13
48+
> * BUGFIX: Specialcase Gu.Reactive extension methods.
49+
> #### 3.4.12
50+
> * BUGFIX: When leaveOpen has default value
51+
> #### 3.4.11
52+
> * BUGFIX IDISP023 handle trivial and.
53+
> * BUGFIX IDISP023 when chained constructors
54+
> * BUGFIX IDISP001 when if statement.
55+
> * BUGFIX IDISP004 when chained leave open.
56+
> #### 3.4.10
57+
> * BUGFIX: Handle using in loop
58+
> #### 3.4.9
59+
> * BUGFIX: IDISP023 Allow touching static reference types.
60+
> * BUGFIX: AD0001: Analyzer 'IDisposableAnalyzers.LocalDeclarationAnalyzer
61+
* Update StyleCop.Analyzers to 1.2.0-beta.333 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.321...1.2.0-beta.333)) \
62+
Notable changes/fixes:
63+
* [23db6c0: Avoid reporting SA1141 (Use tuple syntax) in expression trees](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commit/af356f9b36dc4849a678c0b8c918123fa567913b)
4664

4765
## 2.0.0
4866
* Update IDisposableAnalyzers to 3.4.8. Excerpt from [IDisposableAnalyzers Changelog]:
@@ -68,69 +86,52 @@ Initial release
6886
> * Handle some regressions in Roslyn 3.7
6987
* Update StyleCop.Analyzers to 1.2.0-beta.321 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.312...1.2.0-beta.321)) \
7088
Notable changes/fixes:
71-
* [9c5c071: Support records without braces](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.312...1.2.0-beta.321)
72-
* [46d2e37: Support implicit object creation expressions in SA1129 code fix](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commit/46d2e37fed1e471446f32c88c6bdaf2530239570)
89+
* [9c5c071: Support records without braces](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.312...1.2.0-beta.321)
90+
* [46d2e37: Support implicit object creation expressions in SA1129 code fix](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commit/46d2e37fed1e471446f32c88c6bdaf2530239570)
7391

74-
## 2.0.1
75-
* Update IDisposableAnalyzers to 3.4.13. Excerpt from [IDisposableAnalyzers Changelog]:
76-
> #### 3.4.13
77-
> * BUGFIX: Specialcase Gu.Reactive extension methods.
78-
> #### 3.4.12
79-
> * BUGFIX: When leaveOpen has default value
80-
> #### 3.4.11
81-
> * BUGFIX IDISP023 handle trivial and.
82-
> * BUGFIX IDISP023 when chained constructors
83-
> * BUGFIX IDISP001 when if statement.
84-
> * BUGFIX IDISP004 when chained leave open.
85-
> #### 3.4.10
86-
> * BUGFIX: Handle using in loop
87-
> #### 3.4.9
88-
> * BUGFIX: IDISP023 Allow touching static reference types.
89-
> * BUGFIX: AD0001: Analyzer 'IDisposableAnalyzers.LocalDeclarationAnalyzer
90-
* Update StyleCop.Analyzers to 1.2.0-beta.333 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.321...1.2.0-beta.333)) \
91-
Notable changes/fixes:
92-
* [23db6c0: Avoid reporting SA1141 (Use tuple syntax) in expression trees](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commit/af356f9b36dc4849a678c0b8c918123fa567913b)
92+
## 2.0.0-rc.3
93+
* Update StyleCop.Analyzers to 1.2.0-beta.312 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.261...1.2.0-beta.312))
94+
* Fix compilation error when building an F# project.
9395

94-
## 2.1.0
95-
* Warn when interface method has `public` accessibility modifier (`MESSERLI001`)
96+
## 2.0.0-rc.2
97+
* Update StyleCop.Analyzers to 1.2.0-beta.261. ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.205...1.2.0-beta.261))
9698

97-
## 2.1.1
98-
* Relaxed rules:
99-
* [SA1119](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md) (StatementMustNotUseUnnecessaryParenthesis) is now disabled.
99+
## 2.0.0-rc.1
100+
* Breaking: Treat all nullability warnings as errors.
101+
* Lints involving single line comments have been reduced to warnings to make temporary code commenting easier.
102+
* The hungarian notation rule has been relaxed to allow `js` and `db` since those two are common "false positives".
100103

101-
* Update IDisposableAnalyzers to 3.4.15. Excerpt from [IDisposableAnalyzers Changelog]:
102-
> #### 3.4.15
103-
> * BUGFIX: IDISP005 with ServiceDescriptor
104-
> * BUGFIX: IDISP004 when DisposeWith
105-
> #### 3.4.14
106-
> * BUGFIX: IDISP005 should not warn in Assert.Throws.
107-
> * BUGFIX: Handle function pointer.
108-
> #### 3.4.13
109-
> * BUGFIX: Specialcase Gu.Reactive extension methods.
110-
* Update StyleCop.Analyzers to 1.2.0-beta.354 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.333...1.2.0-beta.354))
104+
## 1.2.1
105+
* Update StyleCop.Analyzers to 1.2.0-beta.205. ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.164...1.2.0-beta.205))
106+
* Update IDisposableAnalyzers to 3.4.1. Excerpt from [IDisposableAnalyzers Changelog]:
107+
> #### 3.4.1
108+
> * Publish with binaries.
109+
> #### 3.4.0
110+
> * FEATURE: Handle DisposableMixins.DisposeWith
111+
> * BUGFIX: IDISP025 when abstract dispose method.
112+
> * BUGFIX: IDISP006 when explicit implementation.
111113
112-
## 2.1.2
113-
* Update StyleCop.Analyzers to 1.2.0-beta.376 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.354...1.2.0-beta.376))
114+
## 1.2.0
115+
* Disable SA1412 (StoreFilesAsUtf). This means that BOMs are no longer required in C# files.
116+
* Update IDisposableAnalyzers from 3.3.2 to 3.3.8:
117+
* Update StyleCop.Analyzers from 1.2.0-beta.113 to 1.2.0-beta.164 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.113...1.2.0-beta.164)).
118+
* Enable `GenerateDocumentationFile` by default. This had to be turned on manually in each project before,
119+
as it is required by our StyleCop configuration.
114120

115-
## 2.1.3
116-
* Update StyleCop.Analyzers to 1.2.0-beta.435 ([diff](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/compare/1.2.0-beta.376...1.2.0-beta.435))
117-
* Most notably this version fixes false positives of `SA1516: Elements should be separated by blank line` in files with top-level statements.
121+
## 1.1.0
122+
* Update IDisposableAnalyzers from 3.2.0 to 3.3.2. Excerpt from [IDisposableAnalyzers Changelog]:
123+
> #### 3.3.0
124+
> - FEATURE: Initial support for AsyncDisposable
125+
126+
## 1.0.1
127+
* Hide stylecop.json in Visual Studio.
128+
129+
## 1.0.0
130+
* Add support for netstandard2.0.
131+
* Add support for projects that target multiple frameworks.
132+
133+
## 1.0.0-alpha.1
134+
Initial release
118135

119-
## 2.2.0
120-
* File scoped namespaces are now enforced. (#81)
121-
* Enable warning for unused usings. (#81)
122-
* `SA1305: FieldNamesMustNotUseHungarianNotation` has been disabled. (#82)
123-
* Use warning instead of error level for spacing rules. (#83)
124-
* Update IDisposableAnalyzers to 4.0.2. Excerpt from [IDisposableAnalyzers Changelog]:
125-
> #### 4.0.2
126-
> * BUGFIX: IDISP007 when disposing static member in static context
127-
> #### 4.0.1
128-
> * BUGFIX: IDISP007 false warning when using Rx
129-
> * BUGFIX: IDISP016 false warning when foreach
130-
> * BUGFIX: Handle leaveOpen when AsyncDisposable
131-
> * BUGIX: Handle top level statements.
132-
> #### 4.0.0
133-
> * BREAKING: For VS2022+ now.
134-
> * BUGFIX: AD0001 -> Could not load file or assembly
135136

136137
[IDisposableAnalyzers Changelog]: https://github.com/DotNetAnalyzers/IDisposableAnalyzers/blob/master/RELEASE_NOTES.md

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"rollForward": "latestFeature"
55
},
66
"msbuild-sdks": {
7-
"Microsoft.Build.NoTargets": "3.5.6"
7+
"Microsoft.Build.NoTargets": "3.7.0"
88
}
99
}

readme.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,6 @@
66

77
## Usage
88

9-
### Without the CentralPackageVersions SDK
10-
11-
Add the following package reference to your project or to your `Directory.Build.props`:
12-
13-
```diff
14-
<?xml version="1.0" encoding="utf-8"?>
15-
<Project>
16-
<ItemGroup>
17-
+ <PackageReference Include="Messerli.CodeStyle" Version="2.1.0" PrivateAssets="all" />
18-
</ItemGroup>
19-
</Project>
20-
```
21-
22-
### With the CentralPackageVersions SDK
23-
24-
Add `Messerli.CodeStyle` to your `Packages.props`:
25-
```diff
26-
<?xml version="1.0" encoding="utf-8"?>
27-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
28-
<ItemGroup Label="Build dependencies">
29-
+ <PackageReference Update="Messerli.CodeStyle" Version="2.1.0" />
30-
</ItemGroup>
31-
</Project>
32-
```
33-
349
Add the following package reference to your project or to your `Directory.Build.props`:
3510
```diff
3611
<?xml version="1.0" encoding="utf-8"?>
@@ -41,6 +16,8 @@ Add the following package reference to your project or to your `Directory.Build.
4116
</Project>
4217
```
4318

19+
You either have to add the version here or in `Directory.Packages.props` depending on if you're using [Central Package Management](https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management).
20+
4421
## Warnings as Errors
4522

4623
Some analyzer rules, such as rules involving single line comments, are configured as warnings to facilitate development.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#r "nuget: Messerli.TempDirectory,0.3.0"
2+
3+
open System.Diagnostics
4+
open System.IO
5+
open System.IO.Compression
6+
open Messerli.TempDirectory
7+
8+
let ensureSuccessExitCode(p: Process) =
9+
if p.ExitCode <> 0 then
10+
raise (IOException($"The process {p.StartInfo.FileName} exited with a non-zero exit code {p.ExitCode}"))
11+
12+
let addArguments (info: ProcessStartInfo) args =
13+
args |> Seq.iter info.ArgumentList.Add
14+
15+
let runProcess filename args =
16+
let formattedArgs = args |> String.concat " "
17+
printfn $"+ {filename} {formattedArgs}"
18+
let startInfo = ProcessStartInfo(filename)
19+
addArguments startInfo args
20+
use p = Process.Start(startInfo)
21+
p.WaitForExit()
22+
ensureSuccessExitCode p
23+
24+
let buildNuGetPackages outputDirectory =
25+
Directory.CreateDirectory(outputDirectory) |> ignore
26+
runProcess "dotnet" ["pack"; "CodeStyle/CodeStyle.csproj"; $"/p:PackageOutputPath={outputDirectory}"]
27+
28+
let findNuGetPackage packagesDirectory =
29+
Directory.GetFiles(packagesDirectory, searchPattern = "*.nupkg") |> Seq.head
30+
31+
let testFileIsImportable packagesDirectory relativePath =
32+
printfn $"Testing {relativePath}"
33+
runProcess "dotnet" ["msbuild"; Path.Combine(packagesDirectory, relativePath); "-preprocess"]
34+
35+
let main =
36+
use tempDirectory = TempSubdirectory.Create("code-style-tests")
37+
let packagesDirectory = Path.Combine(tempDirectory.FullName, "nupkg")
38+
let unpackedDirectory = Path.Combine(tempDirectory.FullName, "unpacked")
39+
let importableFiles = ["build/Messerli.CodeStyle.props"]
40+
buildNuGetPackages packagesDirectory
41+
ZipFile.ExtractToDirectory((findNuGetPackage packagesDirectory), unpackedDirectory)
42+
importableFiles |> Seq.iter (testFileIsImportable unpackedDirectory)
43+
44+
main

0 commit comments

Comments
 (0)