Skip to content

Commit 506649e

Browse files
CopilotBenjaminMichaelis
authored andcommitted
Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com>
1 parent acedbcd commit 506649e

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎Directory.Packages.props‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<Project>
2-
<PropertyGroup>
3-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
5-
</PropertyGroup>
6-
<ItemGroup>
7-
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
8-
<PackageVersion Include="IntelliTect.Analyzers" Version="0.1.8" />
9-
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
10-
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
11-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
12-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
13-
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.103" />
14-
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
16-
<PackageVersion Include="MSTest.TestAdapter" Version="4.1.0" />
17-
<PackageVersion Include="MSTest.TestFramework" Version="4.1.0" />
18-
<PackageVersion Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.23407.1" />
19-
</ItemGroup>
20-
</Project>
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
8+
<PackageVersion Include="IntelliTect.Analyzers" Version="0.1.8" />
9+
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
10+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
11+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
12+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
13+
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.103" />
14+
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="5.0.0" />
15+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
16+
<PackageVersion Include="MSTest.TestAdapter" Version="4.1.0" />
17+
<PackageVersion Include="MSTest.TestFramework" Version="4.1.0" />
18+
<PackageVersion Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.23407.1" />
19+
</ItemGroup>
20+
</Project>

‎IntelliTect.Analyzer/IntelliTect.Analyzer/Analyzers/NamingMethodPascal.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context)
107107

108108
private static bool IsTestMethod(IMethodSymbol methodSymbol)
109109
{
110-
// Test framework namespaces - checking namespace is more flexible than specific attribute names
110+
// Test framework namespaces - any method decorated with an attribute from these namespaces
111+
// is considered a test method and exempt from PascalCase validation
111112
string[] testFrameworkNamespaces =
112113
[
113114
"Xunit", // xUnit (note: namespace is "Xunit", not "XUnit")
@@ -116,7 +117,8 @@ private static bool IsTestMethod(IMethodSymbol methodSymbol)
116117
"TUnit.Core" // TUnit
117118
];
118119

119-
// Fallback attribute names for test environments where namespace metadata may be incomplete
120+
// Fallback attribute names - needed because our test infrastructure (DiagnosticVerifier)
121+
// doesn't add references to test framework assemblies, so ContainingNamespace would be null
120122
string[] commonTestAttributeNames =
121123
[
122124
"TestMethod", "TestMethodAttribute", // MSTest
@@ -135,15 +137,15 @@ private static bool IsTestMethod(IMethodSymbol methodSymbol)
135137
return false;
136138
}
137139

138-
// Check namespace first (more robust for production code)
140+
// Check namespace first (works in production with proper assembly references)
139141
string containingNamespace = attribute.AttributeClass.ContainingNamespace?.ToDisplayString();
140142
if (containingNamespace != null &&
141143
testFrameworkNamespaces.Any(ns => containingNamespace.StartsWith(ns, StringComparison.Ordinal)))
142144
{
143145
return true;
144146
}
145147

146-
// Fallback: check attribute name for common test attributes
148+
// Fallback: check attribute name (needed for test environment)
147149
string attributeName = attribute.AttributeClass.Name;
148150
return commonTestAttributeNames.Contains(attributeName);
149151
});

0 commit comments

Comments
 (0)