Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Feb 15, 2024
1 parent 47d5de9 commit 65f5c87
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context, INamedTypeSymbo

if (methodSymbol.DeclaredAccessibility != Accessibility.Public
|| (!canDiscoverInternals && methodSymbol.GetResultantVisibility() != SymbolVisibility.Public)
|| (canDiscoverInternals && methodSymbol.GetResultantVisibility() == SymbolVisibility.Private))
|| (canDiscoverInternals && methodSymbol.GetResultantVisibility() == SymbolVisibility.Private))
{
context.ReportDiagnostic(methodSymbol.CreateDiagnostic(PublicRule, methodSymbol.Name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ public static void AssemblyInitialize(TestContext context)
await VerifyCS.VerifyAnalyzerAsync(code);
}

public async Task WhenAssemblyInitializeIsInternal_InsidePublicClassWithDiscoverInternals_Diagnostic()
{
var code = """
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: DiscoverInternals]
[TestClass]
public class MyTestClass
{
[AssemblyInitialize]
internal static void {|#0:AssemblyInitialize|}(TestContext context)
{
}
}
""";

await VerifyCS.VerifyAnalyzerAsync(
code,
VerifyCS.Diagnostic(AssemblyInitializeShouldBeValidAnalyzer.PublicRule)
.WithLocation(0)
.WithArguments("AssemblyInitialize"));
}

Check failure on line 76 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L76

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(76,6): error SA1513: (NETCORE_ENGINEERING_TELEMETRY=Build) Closing brace should be followed by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md)

Check failure on line 76 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L76

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(76,6): error SA1513: (NETCORE_ENGINEERING_TELEMETRY=Build) Closing brace should be followed by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md)

Check failure on line 76 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L76

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(76,6): error SA1513: (NETCORE_ENGINEERING_TELEMETRY=Build) Closing brace should be followed by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md)

Check failure on line 76 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L76

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(76,6): error SA1513: (NETCORE_ENGINEERING_TELEMETRY=Build) Closing brace should be followed by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md)
public async Task WhenAssemblyInitializeIsNotOrdinary_Diagnostic()

Check failure on line 77 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L77

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(77,1): error SA1516: (NETCORE_ENGINEERING_TELEMETRY=Build) Elements should be separated by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md)

Check failure on line 77 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L77

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(77,1): error SA1516: (NETCORE_ENGINEERING_TELEMETRY=Build) Elements should be separated by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md)

Check failure on line 77 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L77

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(77,1): error SA1516: (NETCORE_ENGINEERING_TELEMETRY=Build) Elements should be separated by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md)

Check failure on line 77 in test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs#L77

test/UnitTests/MSTest.Analyzers.UnitTests/AssemblyInitializeShouldBeValidAnalyzerTests.cs(77,1): error SA1516: (NETCORE_ENGINEERING_TELEMETRY=Build) Elements should be separated by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md)
{
var code = """
Expand Down

0 comments on commit 65f5c87

Please sign in to comment.