forked from DotNetAnalyzers/ReflectionAnalyzers
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REFL043 First argument must match type. Fix DotNetAnalyzers#180.
Forgot to commit REFL043 separately hence mixed, don't feel like spending time untangling it.
- Loading branch information
1 parent
421e404
commit 155efec
Showing
20 changed files
with
654 additions
and
76 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
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
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
ReflectionAnalyzers.Tests/REFL043FirstArgumentTypeTests/Diagnostics.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 @@ | ||
namespace ReflectionAnalyzers.Tests.REFL043FirstArgumentTypeTests | ||
{ | ||
using Gu.Roslyn.Asserts; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using NUnit.Framework; | ||
|
||
public class Diagnostics | ||
{ | ||
private static readonly DiagnosticAnalyzer Analyzer = new CreateDelegateAnalyzer(); | ||
private static readonly ExpectedDiagnostic ExpectedDiagnostic = ExpectedDiagnostic.Create(REFL043FirstArgumentType.Descriptor); | ||
|
||
[Test] | ||
public void StaticStringVoidFirstArg() | ||
{ | ||
var code = @" | ||
namespace RoslynSandbox | ||
{ | ||
using System; | ||
using System.Reflection; | ||
class C | ||
{ | ||
public static void M(string arg) { } | ||
public static object Get => Delegate.CreateDelegate( | ||
typeof(Action), | ||
new C(), | ||
typeof(C).GetMethod(nameof(M))); | ||
} | ||
}"; | ||
|
||
AnalyzerAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code); | ||
} | ||
} | ||
} |
Oops, something went wrong.