Skip to content

Commit 2712309

Browse files
committed
Add analyzer DLL to package and implement test for assignment triggering
1 parent 25e7766 commit 2712309

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/DataverseAnalyzer/DataverseAnalyzer.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
<None Include="..\..\LICENSE.md" Pack="true" PackagePath="LICENSE.md" />
3030
</ItemGroup>
3131

32+
<ItemGroup>
33+
<None Include="bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers\dotnet\cs\$(AssemblyName).dll" Visible="false" />
34+
</ItemGroup>
35+
3236
<PropertyGroup>
3337
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
3438
</PropertyGroup>

tests/DataverseAnalyzer.Tests/BracesForControlFlowAnalyzerTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,27 @@ private void DoSomething() { }
185185
Assert.Empty(diagnostics);
186186
}
187187

188+
[Fact]
189+
public async Task IfStatementWithAssignmentShouldTrigger()
190+
{
191+
var source = """
192+
class TestClass
193+
{
194+
public void TestMethod()
195+
{
196+
var bla = string.Empty;
197+
198+
if (true)
199+
bla = "bla";
200+
}
201+
}
202+
""";
203+
204+
var diagnostics = await GetDiagnosticsAsync(source);
205+
Assert.Single(diagnostics);
206+
Assert.Equal("CT0001", diagnostics[0].Id);
207+
}
208+
188209
private static async Task<Diagnostic[]> GetDiagnosticsAsync(string source)
189210
{
190211
var syntaxTree = CSharpSyntaxTree.ParseText(source);

0 commit comments

Comments
 (0)