-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add examples for excluding assert methods from analyzer (#376)
- Loading branch information
Showing
11 changed files
with
143 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/FluentAssertions.Analyzers.TestUtils/TestAnalyzerConfigOptionsProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// <copyright file="TestAnalyzerConfigOptionsProvider.cs"> | ||
// Copyright (c) 2022 All Rights Reserved | ||
// </copyright> | ||
// <author>Gérald Barré - https://github.com/meziantou</author> | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
|
||
namespace FluentAssertions.Analyzers.TestUtils; | ||
|
||
public sealed class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider | ||
{ | ||
public static TestAnalyzerConfigOptionsProvider Empty { get; } = new(ImmutableDictionary<string, string>.Empty); | ||
|
||
private readonly IDictionary<string, string> _values; | ||
public TestAnalyzerConfigOptionsProvider(IDictionary<string, string> values) => _values = values; | ||
|
||
public override AnalyzerConfigOptions GlobalOptions => new TestAnalyzerConfigOptions(_values); | ||
public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) => new TestAnalyzerConfigOptions(_values); | ||
public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) => new TestAnalyzerConfigOptions(_values); | ||
|
||
private sealed class TestAnalyzerConfigOptions : AnalyzerConfigOptions | ||
{ | ||
private readonly IDictionary<string, string> _values; | ||
|
||
public TestAnalyzerConfigOptions(IDictionary<string, string> values) => _values = values; | ||
|
||
public override bool TryGetValue(string key, out string value) | ||
{ | ||
return _values.TryGetValue(key, out value); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/FluentAssertions.Analyzers.Tests/CodeFixVerifierArguments.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/FluentAssertions.Analyzers.Tests/Tips/FluentAssertionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/FluentAssertions.Analyzers.Tests/Tips/NullConditionalAssertionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.