├── .gitattributes
├── .github
├── FUNDING.yml
└── workflows
│ ├── benchmark.yml
│ ├── ci.yml
│ ├── integration.yml
│ └── release.yml
├── .gitignore
├── FluentAssertions.Analyzers.sln
├── ISSUE_TEMPLATE.md
├── LICENSE
├── README.md
├── assets
├── FluentAssertions.png
├── demo.gif
└── images
│ └── fluent_assertions_analyzers_large_horizontal.svg
├── docs
├── FluentAssertionsAnalyzer.md
├── MsTestAnalyzer.md
├── Nunit3Analyzer.md
├── Nunit4Analyzer.md
└── XunitAnalyzer.md
├── scripts
├── generate-docs.ps1
└── run-docs-tests.ps1
└── src
├── Directory.Packages.props
├── FluentAssertions.Analyzers.BenchmarkTests
├── FluentAssertions.Analyzers.BenchmarkTests.csproj
├── FluentAssertionsBenchmarks.cs
└── Program.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit3
├── ExpectedAssertionExceptionAttribute.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit3.csproj
├── Nunit3AnalyzerTests.cs
└── Program.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit4
├── ExpectedAssertionExceptionAttribute.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit4.csproj
├── Nunit4AnalyzerTests.cs
└── Program.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Xunit
├── ExpectedAssertionExceptionAttribute.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Xunit.csproj
├── Program.cs
└── XunitAnalyzerTests.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.csproj
├── FluentAssertionsAnalyzerTests.cs
├── MsTestAnalyzerTests.cs
└── Program.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator
├── DocsGenerator.cs
├── DocsVerifier.cs
├── FluentAssertionAnalyzerDocsUtils.cs
├── FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator.csproj
└── ProgramUtils.cs
├── FluentAssertions.Analyzers.TestUtils
├── CodeAnalyzersUtils.cs
├── CsProjectArguments.cs
├── CsProjectGenerator.cs
├── FluentAssertions.Analyzers.TestUtils.csproj
├── GenerateCode.cs
├── PackageReference.cs
├── SolutionExtensions.cs
├── TargetFramework.cs
└── TestAnalyzerConfigOptionsProvider.cs
├── FluentAssertions.Analyzers.Tests
├── CodeFixVerifierArguments.cs
├── DiagnosticResult.cs
├── DiagnosticVerifier.cs
├── DiagnosticVerifierArguments.cs
├── FluentAssertions.Analyzers.Tests.csproj
├── TestAttributes.cs
├── TestConfiguration.cs
└── Tips
│ ├── AsyncVoidTests.cs
│ ├── CollectionTests.cs
│ ├── DictionaryTests.cs
│ ├── ExceptionsTests.cs
│ ├── FluentAssertionsTests.cs
│ ├── MsTestTests.cs
│ ├── NullConditionalAssertionTests.cs
│ ├── NumericTests.cs
│ ├── NunitTests.cs
│ ├── SanityTests.cs
│ ├── ShouldEqualsTests.cs
│ ├── StringTests.cs
│ └── XunitTests.cs
└── FluentAssertions.Analyzers
├── AnalyzerReleases.Shipped.md
├── AnalyzerReleases.Unshipped.md
├── Constants.cs
├── FluentAssertions.Analyzers.csproj
├── Tips
├── AssertAnalyzer.cs
├── AsyncVoid.cs
├── CodeFixProviderBase.cs
├── DiagnosticMetadata.cs
├── DocumentEditorUtils.cs
├── Editing
│ ├── CreateEquivalencyAssertionOptionsLambda.cs
│ ├── EditAction.cs
│ ├── IEditAction.cs
│ ├── SkipInvocationNodeAction.cs
│ ├── SkipMemberAccessNodeAction.cs
│ ├── SubjectShouldAssertionAction.cs
│ └── SubjectShouldGenericAssertionAction.cs
├── FluentAssertionsAnalyzer.Utils.cs
├── FluentAssertionsAnalyzer.cs
├── FluentAssertionsCodeFixProvider.EditorUtils.cs
├── FluentAssertionsCodeFixProvider.Exceptions.cs
├── FluentAssertionsCodeFixProvider.cs
├── FluentAssertionsEditAction.cs
├── FluentChainedAssertionEditAction.cs
├── MsTestCodeFixProvider.cs
├── NunitCodeFixProvider.cs
├── TestingFrameworkCodeFixProvider.cs
└── XunitCodeFixProvider.cs
├── Utilities
├── OperartionExtensions.cs
└── TypesExtensions.cs
└── tools
├── install.ps1
└── uninstall.ps1
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [meir017]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ['https://www.buymeacoffee.com/meirblachmq']
13 |
--------------------------------------------------------------------------------
/.github/workflows/benchmark.yml:
--------------------------------------------------------------------------------
1 | name: Benchmark tests
2 | on: [pull_request]
3 |
4 | permissions:
5 | contents: write
6 | deployments: write
7 |
8 | jobs:
9 | benchmark:
10 | name: Performance regression check
11 | runs-on: ubuntu-22.04
12 | if: github.repository == 'fluentassertions/fluentassertions.analyzers'
13 | steps:
14 | - uses: actions/checkout@v4
15 | - name: Setup .NET
16 | uses: actions/setup-dotnet@v4
17 | with:
18 | dotnet-version: '6.x'
19 | - name: Setup .NET
20 | uses: actions/setup-dotnet@v4
21 | with:
22 | dotnet-version: '7.x'
23 | - name: Run benchmark
24 | run: cd src/FluentAssertions.Analyzers.BenchmarkTests && dotnet run -c Release --exporters json --filter '*'
25 |
26 | - name: Store benchmark result
27 | uses: benchmark-action/github-action-benchmark@v1.18.0
28 | with:
29 | name: FluentAssertions.Analyzers Benchmark
30 | tool: 'benchmarkdotnet'
31 | output-file-path: src/FluentAssertions.Analyzers.BenchmarkTests/BenchmarkDotNet.Artifacts/results/FluentAssertions.Analyzers.BenchmarkTests.FluentAssertionsBenchmarks-report.json
32 | github-token: ${{ secrets.GITHUB_TOKEN }}
33 | auto-push: true
34 | alert-threshold: '200%'
35 | comment-on-alert: true
36 | fail-on-alert: true
37 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | pull_request:
4 | branches:
5 | - main
6 | push:
7 | branches:
8 | - main
9 | jobs:
10 | build:
11 | strategy:
12 | matrix:
13 | os: [ubuntu-22.04, windows-2022, macos-14]
14 | config: [Debug, Release]
15 | runs-on: ${{ matrix.os }}
16 | env:
17 | NUGET_CERT_REVOCATION_MODE: offline
18 | steps:
19 | - uses: actions/checkout@v4
20 | with:
21 | fetch-depth: 0
22 | - name: Setup .NET 6
23 | uses: actions/setup-dotnet@v4
24 | with:
25 | dotnet-version: 6.0.x
26 | - run: dotnet build
27 | - run: dotnet test src/FluentAssertions.Analyzers.Tests --configuration Release --filter 'TestCategory=Completed' /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
28 | - run: dotnet pack src/FluentAssertions.Analyzers/FluentAssertions.Analyzers.csproj
29 |
--------------------------------------------------------------------------------
/.github/workflows/integration.yml:
--------------------------------------------------------------------------------
1 | name: Integration
2 | on:
3 | pull_request:
4 | branches:
5 | - main
6 | push:
7 | branches:
8 | - main
9 | jobs:
10 | build:
11 | strategy:
12 | matrix:
13 | os: [ubuntu-22.04, windows-2022, macos-14]
14 | runs-on: ${{ matrix.os }}
15 | env:
16 | NUGET_CERT_REVOCATION_MODE: offline
17 | steps:
18 | - uses: actions/checkout@v4
19 | with:
20 | fetch-depth: 0
21 | - name: Setup .NET 8
22 | uses: actions/setup-dotnet@v4
23 | with:
24 | dotnet-version: 8.0.x
25 | - run: dotnet test src/FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs # before formatting
26 | - name: Run the docs generator
27 | shell: pwsh
28 | run: ./scripts/generate-docs.ps1 -ValidateNoChanges
29 | - name: Run the docs tests and format, then test again
30 | shell: pwsh
31 | run: ./scripts/run-docs-tests.ps1 -FormatAndExecuteTestsAgain
32 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Publish NuGet package
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*'
7 |
8 | jobs:
9 | publish:
10 | runs-on: ubuntu-22.04
11 | steps:
12 | - name: Checkout code
13 | uses: actions/checkout@v4
14 |
15 | - name: Setup .NET Core
16 | uses: actions/setup-dotnet@v4
17 | with:
18 | dotnet-version: '6.x'
19 |
20 | - name: Restore dependencies
21 | run: dotnet restore
22 |
23 | - name: Build & Pack NuGet package
24 | shell: pwsh
25 | run: |
26 | $tag = $env:GITHUB_REF.Substring('refs/tags/v'.Length)
27 | dotnet pack src/FluentAssertions.Analyzers/ --output out --configuration Release --include-symbols -p:Version=$tag
28 |
29 | - name: Publish NuGet package
30 | shell: pwsh
31 | run: |
32 | $symbols = Get-ChildItem out/*.symbols.nupkg | ForEach-Object FullName;
33 | foreach ($symbol in $symbols) {
34 | Write-Host "Pushing symbols $symbol";
35 | $nupkg = $symbol.Replace(".symbols.nupkg",".nupkg");
36 | Write-Host "Pushing nupkg $nupkg";
37 | dotnet nuget push $nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json;
38 | }
39 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
262 | /tools
263 |
--------------------------------------------------------------------------------
/FluentAssertions.Analyzers.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.8.34601.278
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers.Tests", "src\FluentAssertions.Analyzers.Tests\FluentAssertions.Analyzers.Tests.csproj", "{979824BD-5936-4969-B43B-BF613B3C0C5F}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{1D2F0A0B-7B98-49D6-BD83-E750A2DD7FD0}"
9 | ProjectSection(SolutionItems) = preProject
10 | .gitattributes = .gitattributes
11 | .gitignore = .gitignore
12 | .github\workflows\ci.yml = .github\workflows\ci.yml
13 | LICENSE = LICENSE
14 | README.md = README.md
15 | EndProjectSection
16 | EndProject
17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers", "src\FluentAssertions.Analyzers\FluentAssertions.Analyzers.csproj", "{3BA672F7-00D8-4E77-89A0-D46DD99D35AA}"
18 | EndProject
19 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers.TestUtils", "src\FluentAssertions.Analyzers.TestUtils\FluentAssertions.Analyzers.TestUtils.csproj", "{BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}"
20 | EndProject
21 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers.BenchmarkTests", "src\FluentAssertions.Analyzers.BenchmarkTests\FluentAssertions.Analyzers.BenchmarkTests.csproj", "{FE6D8A05-1383-4BCD-AD65-2EF741E48F44}"
22 | EndProject
23 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8EFE7955-E63C-4055-A9FF-76C7CE0A1151}"
24 | EndProject
25 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs", "src\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.csproj", "{2F84FE09-8CB4-48AE-A119-671C509213CF}"
26 | EndProject
27 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{48BE11CB-8BAF-4099-9D93-AE9BB74BB190}"
28 | EndProject
29 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{72192514-FA22-4699-8EE1-39D34CFE1025}"
30 | EndProject
31 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator", "src\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocsGenerator.csproj", "{2871B22C-AEFC-4C33-9BBF-695699E61B57}"
32 | EndProject
33 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit4", "src\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit4\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit4.csproj", "{A819A8A5-C8F7-46AD-B0F2-44868070A188}"
34 | EndProject
35 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit3", "src\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit3\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Nunit3.csproj", "{FBCDB423-7729-42CD-9279-2D0BECE37907}"
36 | EndProject
37 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Xunit", "src\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Xunit\FluentAssertions.Analyzers.FluentAssertionAnalyzerDocs.Xunit.csproj", "{94D58487-F555-45A1-8076-511D1792C1DE}"
38 | EndProject
39 | Global
40 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
41 | Debug|Any CPU = Debug|Any CPU
42 | Release|Any CPU = Release|Any CPU
43 | EndGlobalSection
44 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
45 | {979824BD-5936-4969-B43B-BF613B3C0C5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {979824BD-5936-4969-B43B-BF613B3C0C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {979824BD-5936-4969-B43B-BF613B3C0C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {979824BD-5936-4969-B43B-BF613B3C0C5F}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {3BA672F7-00D8-4E77-89A0-D46DD99D35AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {3BA672F7-00D8-4E77-89A0-D46DD99D35AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {3BA672F7-00D8-4E77-89A0-D46DD99D35AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {3BA672F7-00D8-4E77-89A0-D46DD99D35AA}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}.Release|Any CPU.ActiveCfg = Release|Any CPU
56 | {BD9FC8CC-C23D-4ECC-A926-4BE35C78D338}.Release|Any CPU.Build.0 = Release|Any CPU
57 | {FE6D8A05-1383-4BCD-AD65-2EF741E48F44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58 | {FE6D8A05-1383-4BCD-AD65-2EF741E48F44}.Debug|Any CPU.Build.0 = Debug|Any CPU
59 | {FE6D8A05-1383-4BCD-AD65-2EF741E48F44}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {FE6D8A05-1383-4BCD-AD65-2EF741E48F44}.Release|Any CPU.Build.0 = Release|Any CPU
61 | {2F84FE09-8CB4-48AE-A119-671C509213CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62 | {2F84FE09-8CB4-48AE-A119-671C509213CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
63 | {2F84FE09-8CB4-48AE-A119-671C509213CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
64 | {2F84FE09-8CB4-48AE-A119-671C509213CF}.Release|Any CPU.Build.0 = Release|Any CPU
65 | {2871B22C-AEFC-4C33-9BBF-695699E61B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66 | {2871B22C-AEFC-4C33-9BBF-695699E61B57}.Debug|Any CPU.Build.0 = Debug|Any CPU
67 | {2871B22C-AEFC-4C33-9BBF-695699E61B57}.Release|Any CPU.ActiveCfg = Release|Any CPU
68 | {2871B22C-AEFC-4C33-9BBF-695699E61B57}.Release|Any CPU.Build.0 = Release|Any CPU
69 | {A819A8A5-C8F7-46AD-B0F2-44868070A188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
70 | {A819A8A5-C8F7-46AD-B0F2-44868070A188}.Debug|Any CPU.Build.0 = Debug|Any CPU
71 | {A819A8A5-C8F7-46AD-B0F2-44868070A188}.Release|Any CPU.ActiveCfg = Release|Any CPU
72 | {A819A8A5-C8F7-46AD-B0F2-44868070A188}.Release|Any CPU.Build.0 = Release|Any CPU
73 | {FBCDB423-7729-42CD-9279-2D0BECE37907}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
74 | {FBCDB423-7729-42CD-9279-2D0BECE37907}.Debug|Any CPU.Build.0 = Debug|Any CPU
75 | {FBCDB423-7729-42CD-9279-2D0BECE37907}.Release|Any CPU.ActiveCfg = Release|Any CPU
76 | {FBCDB423-7729-42CD-9279-2D0BECE37907}.Release|Any CPU.Build.0 = Release|Any CPU
77 | {94D58487-F555-45A1-8076-511D1792C1DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
78 | {94D58487-F555-45A1-8076-511D1792C1DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
79 | {94D58487-F555-45A1-8076-511D1792C1DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
80 | {94D58487-F555-45A1-8076-511D1792C1DE}.Release|Any CPU.Build.0 = Release|Any CPU
81 | EndGlobalSection
82 | GlobalSection(SolutionProperties) = preSolution
83 | HideSolutionNode = FALSE
84 | EndGlobalSection
85 | GlobalSection(NestedProjects) = preSolution
86 | {979824BD-5936-4969-B43B-BF613B3C0C5F} = {48BE11CB-8BAF-4099-9D93-AE9BB74BB190}
87 | {3BA672F7-00D8-4E77-89A0-D46DD99D35AA} = {8EFE7955-E63C-4055-A9FF-76C7CE0A1151}
88 | {BD9FC8CC-C23D-4ECC-A926-4BE35C78D338} = {48BE11CB-8BAF-4099-9D93-AE9BB74BB190}
89 | {FE6D8A05-1383-4BCD-AD65-2EF741E48F44} = {48BE11CB-8BAF-4099-9D93-AE9BB74BB190}
90 | {2F84FE09-8CB4-48AE-A119-671C509213CF} = {72192514-FA22-4699-8EE1-39D34CFE1025}
91 | {2871B22C-AEFC-4C33-9BBF-695699E61B57} = {72192514-FA22-4699-8EE1-39D34CFE1025}
92 | {A819A8A5-C8F7-46AD-B0F2-44868070A188} = {8EFE7955-E63C-4055-A9FF-76C7CE0A1151}
93 | {FBCDB423-7729-42CD-9279-2D0BECE37907} = {8EFE7955-E63C-4055-A9FF-76C7CE0A1151}
94 | {94D58487-F555-45A1-8076-511D1792C1DE} = {8EFE7955-E63C-4055-A9FF-76C7CE0A1151}
95 | EndGlobalSection
96 | GlobalSection(ExtensibilityGlobals) = postSolution
97 | SolutionGuid = {4BF3D005-625C-4CEC-B3FB-298B956402BE}
98 | EndGlobalSection
99 | EndGlobal
100 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Description
2 |
3 | [Description of the issue]
4 |
5 | ### Complete minimal example reproducing the issue
6 |
7 | Complete means the code snippet can be copied into a unit test method in a fresh C# project and run.
8 | Minimal means it is stripped from code not related to reproducing the issue.
9 |
10 | E.g.
11 |
12 | ```csharp
13 | // Arrange
14 | string input = "MyString";
15 |
16 | // Act
17 | char result = input[0];
18 |
19 | // Assert
20 | result.Should().Be('M');
21 | ```
22 |
23 | ### Expected behavior:
24 |
25 | [What you expect to happen]
26 |
27 | ### Actual behavior:
28 |
29 | [What actually happens]
30 |
31 | ### Versions
32 |
33 | * Which version of Fluent Assertions Analyzers are you using?
34 | * Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.0.
35 |
36 | ### Additional Information
37 |
38 | Any additional information, configuration or data that might be necessary to reproduce the issue.
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Meir Blachman
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Extension methods to fluently assert the outcome of .NET tests
4 |
5 | [](https://github.com/fluentassertions/fluentassertions.analyzers/actions/workflows/ci.yml)
6 | [](https://github.com/fluentassertions/fluentassertions.analyzers/releases/latest)
7 | [](https://www.nuget.org/packages/fluentassertions.analyzers)
8 | [](https://libraries.io/nuget/fluentassertions.analyzers)
9 | [](https://github.com/fluentassertions/fluentassertions.analyzers/stargazers)
10 | [](https://github.com/fluentassertions/fluentassertions.analyzers/graphs/contributors)
11 | [](https://github.com/fluentassertions/fluentassertions.analyzers)
12 | [](https://github.com/fluentassertions/fluentassertions.analyzers/graphs/commit-activity)
13 | [](https://github.com/fluentassertions/fluentassertions.analyzers/issues)
14 |
15 | A collection of Analyzers based on the best practices [tips](https://fluentassertions.com/tips/).
16 |
17 | 
18 |
19 | ## Analysis and Code Fix in Action
20 |
21 | 
22 |
23 | ## Install
24 |
25 | using the latest stable version:
26 |
27 | ```powershell
28 | dotnet add package FluentAssertions.Analyzers
29 | ```
30 |
31 | ## Docs
32 |
33 | - [FluentAssertions Analyzer Docs](docs/FluentAssertionsAnalyzer.md)
34 | - [MsTest Analyzer Docs](docs/MsTestAnalyzer.md)
35 | - [NUnit4 Analyzer Docs](docs/Nunit4Analyzer.md)
36 | - [NUnit3 Analyzer Docs](docs/Nunit3Analyzer.md)
37 | - [Xunit Analyzer Docs](docs/XunitAnalyzer.md)
38 |
39 | ## Configuration
40 |
41 | © Thanks to https://github.com/meziantou/Meziantou.FluentAssertionsAnalyzers
42 |
43 | You can exclude assertion methods using the `.editorconfig` file:
44 |
45 | ```ini
46 | [*.cs]
47 | ffa_excluded_methods=M:NUnit.Framework.Assert.Fail;M:NUnit.Framework.Assert.Fail(System.String)
48 | ```
49 |
50 | ## Getting Started
51 |
52 | ### Build
53 |
54 | ```bash
55 | dotnet build
56 | ```
57 |
58 | ### Tests
59 |
60 | ```bash
61 | dotnet test --configuration Release --filter 'TestCategory=Completed'
62 | ```
63 |
64 | ### Benchmarks
65 |
66 | https://fluentassertions.github.io/fluentassertions.analyzers/dev/bench/
67 |
68 | ## Example Usages
69 | - https://github.com/SonarSource/sonar-dotnet/pull/2072
70 | - https://github.com/microsoft/component-detection/pull/634
71 | - https://github.com/microsoft/onefuzz/pull/3314
72 | - https://github.com/chocolatey/choco/pull/2908
73 |
--------------------------------------------------------------------------------
/assets/FluentAssertions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluentassertions/fluentassertions.analyzers/2fe5f040fa2d192d98f76bfd66003e157983b3be/assets/FluentAssertions.png
--------------------------------------------------------------------------------
/assets/demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluentassertions/fluentassertions.analyzers/2fe5f040fa2d192d98f76bfd66003e157983b3be/assets/demo.gif
--------------------------------------------------------------------------------
/docs/XunitAnalyzer.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # Xunit Analyzer Docs
6 |
7 | - [AssertTrue](#scenario-asserttrue) - `flag.Should().BeTrue();`
8 | - [AssertFalse](#scenario-assertfalse) - `flag.Should().BeFalse();`
9 | - [AssertSame](#scenario-assertsame) - `obj1.Should().BeSameAs(obj2);`
10 | - [AssertNotSame](#scenario-assertnotsame) - `obj1.Should().NotBeSameAs(obj2);`
11 | - [AssertDoubleEqual](#scenario-assertdoubleequal) - `actual.Should().BeApproximately(expected, tolerance);`
12 | - [AssertDateTimeEqual](#scenario-assertdatetimeequal) - `actual.Should().BeCloseTo(expected, TimeSpan.FromDays(3));`
13 | - [AssertObjectEqual](#scenario-assertobjectequal) - `actual.Should().Be(expected);`
14 | - [AssertObjectEqualWithComparer](#scenario-assertobjectequalwithcomparer) - `actual.Should().BeEquivalentTo(expected, options => options.Using(EqualityComparer