Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions TUnit.Analyzers/AbstractTestClassWithDataSourcesAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,7 @@ private void AnalyzeSymbol(SymbolAnalysisContext context)
return false;
}

// Check for data source attributes
var currentType = attributeClass;
while (currentType != null)
{
var typeName = currentType.Name;

// Check for known data source attributes
if (typeName.Contains("DataSource") || typeName == "ArgumentsAttribute")
{
return true;
}

currentType = currentType.BaseType;
}

// Also check if it implements IDataSourceAttribute
// Check if it implements IDataSourceAttribute
return attributeClass.AllInterfaces.Any(i =>
i.GloballyQualified() == WellKnown.AttributeFullyQualifiedClasses.IDataSourceAttribute.WithGlobalPrefix);
});
Expand Down Expand Up @@ -103,8 +88,8 @@ private static bool HasConcreteInheritingClassesWithInheritsTests(SymbolAnalysis
{
hasAnyConcreteSubclasses = false;

// Get all named types in the compilation (including referenced assemblies)
var allTypes = GetAllNamedTypes(context.Compilation.GlobalNamespace);
// Get all named types in the source assembly only (not referenced assemblies)
var allTypes = GetAllNamedTypes(context.Compilation.Assembly.GlobalNamespace);

// Check if any concrete class inherits from the abstract class and has [InheritsTests]
foreach (var type in allTypes)
Expand All @@ -115,12 +100,6 @@ private static bool HasConcreteInheritingClassesWithInheritsTests(SymbolAnalysis
continue;
}

// Only consider types that are defined in source (not from referenced assemblies)
if (!type.Locations.Any(l => l.IsInSource))
{
continue;
}

// Check if this type inherits from our abstract class
var baseType = type.BaseType;
while (baseType != null)
Expand Down
Loading