Skip to content

Commit

Permalink
chore: remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rannes committed Oct 17, 2024
1 parent a40aaf7 commit 3f7e260
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static readonly LocalizableString Description
DiagnosticSeverity.Error,
AnalyzerConstants.EnabledByDefault,
Description,
"https://github.com/agoda-com/AgodaAnalyzers/issues/190",
"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/AG0043.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Descriptor);
Expand All @@ -50,30 +50,24 @@ private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
var invocationExpr = (InvocationExpressionSyntax)context.Node;

// Check if it's a member access (e.g., something.BuildServiceProvider())
if (!(invocationExpr.Expression is MemberAccessExpressionSyntax memberAccessExpr))
return;

Check warning on line 54 in src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs#L54

Added line #L54 was not covered by tests

// Check if the method name is BuildServiceProvider
if (memberAccessExpr.Name.Identifier.ValueText != "BuildServiceProvider")
return;

// Get the method symbol
var methodSymbol = context.SemanticModel.GetSymbolInfo(invocationExpr).Symbol as IMethodSymbol;
if (methodSymbol == null)
return;

Check warning on line 61 in src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs#L61

Added line #L61 was not covered by tests

// Verify it's from the correct namespace
if (!methodSymbol.ContainingNamespace.ToDisplayString()
.StartsWith("Microsoft.Extensions.DependencyInjection"))
return;

Check warning on line 65 in src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs#L65

Added line #L65 was not covered by tests

// Get the containing type that defines the BuildServiceProvider method
var containingType = methodSymbol.ContainingType;
if (containingType == null)
return;

Check warning on line 69 in src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs#L69

Added line #L69 was not covered by tests

// Check if the containing type is an extension method class for IServiceCollection
var isServiceCollectionExtension = containingType
.GetTypeMembers()
.SelectMany(t => t.GetMembers())

Check warning on line 73 in src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs

View check run for this annotation

Codecov / codecov/patch

src/Agoda.Analyzers/AgodaCustom/AG0043NoBuildServiceProvider.cs#L73

Added line #L73 was not covered by tests
Expand All @@ -82,7 +76,6 @@ private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
m.Parameters[0].Type.ToDisplayString() ==
"Microsoft.Extensions.DependencyInjection.IServiceCollection");

// For extension methods, check the type of the expression being extended
var expressionType = context.SemanticModel.GetTypeInfo(memberAccessExpr.Expression).Type;
var isExpressionServiceCollection = expressionType != null &&
(expressionType.AllInterfaces.Any(i =>
Expand Down

0 comments on commit 3f7e260

Please sign in to comment.