Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rocket Surgery Testing to v8.0.15 #1045

Merged
merged 3 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.31.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.FakeItEasy" Version="8.0.13" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.XUnit" Version="8.0.13" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.SourceGenerators" Version="8.0.13" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.FakeItEasy" Version="8.0.15" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.XUnit" Version="8.0.15" />
<PackageVersion Include="Rocket.Surgery.Extensions.Testing.SourceGenerators" Version="8.0.15" />
<PackageVersion Include="Verify.Xunit" Version="23.5.2" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageVersion Include="xunit" Version="2.7.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ List<ITypeFilterDescriptor> typeFilters

var allAssemblyReferences = assemblyReferences
.Concat(assemblies.OfType<CompiledAssemblyDescriptor>().Select(z => z.TypeFromAssembly.ContainingAssembly))
.Distinct(SymbolEqualityComparer.Default);
.Distinct(SymbolEqualityComparer.Default)
.OfType<IAssemblySymbol>();

types = TypeSymbolVisitor.GetTypes(compilation, allAssemblyReferences);
}
Expand Down
19 changes: 12 additions & 7 deletions src/DependencyInjection.Analyzers/TypeSymbolVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@

namespace Rocket.Surgery.DependencyInjection.Analyzers;

internal class TypeSymbolVisitor : SymbolVisitor
internal class TypeSymbolVisitor(Compilation compilation) : SymbolVisitor
{
public static ImmutableArray<INamedTypeSymbol> GetTypes(Compilation compilation)
{
var visitor = new TypeSymbolVisitor();
var visitor = new TypeSymbolVisitor(compilation);
visitor.VisitNamespace(compilation.GlobalNamespace);
foreach (var symbol in compilation.References.Select(compilation.GetAssemblyOrModuleSymbol).Where(z => z != null))
symbol?.Accept(visitor);
return visitor.GetTypes();
}

public static ImmutableArray<INamedTypeSymbol> GetTypes(Compilation compilation, IEnumerable<ISymbol?> symbols)
public static ImmutableArray<INamedTypeSymbol> GetTypes(Compilation compilation, IEnumerable<IAssemblySymbol> symbols)
{
var visitor = new TypeSymbolVisitor();
var visitor = new TypeSymbolVisitor(compilation);
visitor.Accept(symbols);
return visitor.GetTypes();
}

private readonly List<INamedTypeSymbol> _types = new List<INamedTypeSymbol>();
private readonly List<INamedTypeSymbol> _types = new();

private void Accept<T>(IEnumerable<T> members)
where T : ISymbol?
{
foreach (var member in members)
{
member?.Accept(this);
}
}

public override void VisitNamespace(INamespaceSymbol symbol)
Expand All @@ -42,9 +44,12 @@ public override void VisitAssembly(IAssemblySymbol symbol)

public override void VisitNamedType(INamedTypeSymbol symbol)
{
if (symbol.TypeKind == TypeKind.Class || symbol.TypeKind == TypeKind.Delegate || symbol.TypeKind == TypeKind.Struct)
if (symbol.TypeKind is TypeKind.Class or TypeKind.Delegate or TypeKind.Struct)
{
if (symbol.IsAbstract || !symbol.CanBeReferencedByName) return;
if (Helpers
.GetBaseTypes(compilation, symbol)
.Contains(compilation.GetTypeByMetadataName("System.Attribute"), SymbolEqualityComparer.Default)) return;
_types.Add(symbol);
}

Expand All @@ -55,4 +60,4 @@ public ImmutableArray<INamedTypeSymbol> GetTypes()
{
return _types.Distinct(SymbolEqualityComparer.Default).OfType<INamedTypeSymbol>().ToImmutableArray();
}
}
}
11 changes: 1 addition & 10 deletions test/DependencyInjection.Analyzers.Tests/ModuleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class ModuleInitializer
[ModuleInitializer]
public static void Init()
{
VerifyGeneratorTextContext.Initialize(false, true, DiagnosticSeverity.Error);
VerifyGeneratorTextContext.Initialize(DiagnosticSeverity.Error, Customizers.Default, Customizers.ExcludeParseOptions);

VerifierSettings.AddExtraSettings(
settings => { settings.Converters.Add(new ServiceDescriptorConverter()); }
Expand Down Expand Up @@ -57,15 +57,6 @@ private static ConversionResult Convert(GeneratorTestResultsWithServices result,
}

var data = new Dictionary<string, object>();
// start here
data["ParseOptions"] = new
{
target.ParseOptions.LanguageVersion,
target.ParseOptions.DocumentationMode,
target.ParseOptions.Kind,
target.ParseOptions.Features,
target.ParseOptions.PreprocessorSymbolNames,
};

data["GlobalOptions"] = target.GlobalOptions;
data["FileOptions"] = target.FileOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
GlobalOptions: {
compiled_scan_assembly_load: false
},
ParseOptions: {
LanguageVersion: CSharp10,
DocumentationMode: Parse
},
References: [
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Microsoft.Extensions.DependencyInjection.Abstractions.dll,
Expand Down
Loading
Loading