@@ -110,12 +110,23 @@ private static bool IsTestMethod(IMethodSymbol methodSymbol)
110110 // Test framework namespaces - checking namespace is more flexible than specific attribute names
111111 string [ ] testFrameworkNamespaces =
112112 [
113- "Xunit" , // xUnit
113+ "Xunit" , // xUnit (note: namespace is "Xunit", not "XUnit")
114114 "NUnit.Framework" , // NUnit
115115 "Microsoft.VisualStudio.TestTools.UnitTesting" , // MSTest
116116 "TUnit.Core" // TUnit
117117 ] ;
118118
119+ // Fallback attribute names for test environments where namespace metadata may be incomplete
120+ string [ ] commonTestAttributeNames =
121+ [
122+ "TestMethod" , "TestMethodAttribute" , // MSTest
123+ "Fact" , "FactAttribute" , // xUnit
124+ "Theory" , "TheoryAttribute" , // xUnit
125+ "Test" , "TestAttribute" , // NUnit
126+ "TestCase" , "TestCaseAttribute" , // NUnit
127+ "TestCaseSource" , "TestCaseSourceAttribute" // NUnit
128+ ] ;
129+
119130 ImmutableArray < AttributeData > attributes = methodSymbol . GetAttributes ( ) ;
120131 return attributes . Any ( attribute =>
121132 {
@@ -133,14 +144,8 @@ private static bool IsTestMethod(IMethodSymbol methodSymbol)
133144 }
134145
135146 // Fallback: check attribute name for common test attributes
136- // This helps in test environments where namespace metadata may be incomplete
137147 string attributeName = attribute . AttributeClass . Name ;
138- return attributeName == "TestMethod" || attributeName == "TestMethodAttribute" ||
139- attributeName == "Fact" || attributeName == "FactAttribute" ||
140- attributeName == "Theory" || attributeName == "TheoryAttribute" ||
141- attributeName == "Test" || attributeName == "TestAttribute" ||
142- attributeName == "TestCase" || attributeName == "TestCaseAttribute" ||
143- attributeName == "TestCaseSource" || attributeName == "TestCaseSourceAttribute" ;
148+ return commonTestAttributeNames . Contains ( attributeName ) ;
144149 } ) ;
145150 }
146151 }
0 commit comments