Skip to content

Commit 1788ede

Browse files
Fix ignored Namespace attribute in OperationLightupGenerator
Most of the wrapped `IOperation`s are in `Microsoft.CodeAnalysis.Operations` namespace and there are 6 more of them in `FlowAnalysis` namespace: ``` Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation ``` This alternation is already configured in the `OperationInterfaces.xml` file, but the `Namespace` attribute was ignored in the code. https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/a559b3e58af09387aadc1372a504f9208bce4909/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/OperationInterfaces.xml#L2542
1 parent a559b3e commit 1788ede

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/OperationLightupGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private void GenerateOperationInterface(in GeneratorExecutionContext context, In
6969
variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(
7070
identifier: SyntaxFactory.Identifier("WrappedTypeName"),
7171
argumentList: null,
72-
initializer: SyntaxFactory.EqualsValueClause(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal("Microsoft.CodeAnalysis.Operations." + node.InterfaceName))))))));
72+
initializer: SyntaxFactory.EqualsValueClause(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal($"Microsoft.CodeAnalysis.{node.Namespace}.{node.InterfaceName}"))))))));
7373

7474
// private static readonly Type WrappedType;
7575
members = members.Add(SyntaxFactory.FieldDeclaration(
@@ -988,6 +988,7 @@ public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(s
988988

989989
this.OperationKinds = operationKinds;
990990
this.InterfaceName = node.Attribute("Name").Value;
991+
this.Namespace = node.Attribute("Namespace")?.Value ?? "Operations";
991992
this.Name = this.InterfaceName.Substring("I".Length, this.InterfaceName.Length - "I".Length - "Operation".Length);
992993
this.WrapperName = this.InterfaceName + "Wrapper";
993994
this.BaseInterfaceName = node.Attribute("Base").Value;
@@ -999,6 +1000,8 @@ public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(s
9991000

10001001
public string InterfaceName { get; }
10011002

1003+
public string Namespace { get; }
1004+
10021005
public string Name { get; }
10031006

10041007
public string WrapperName { get; }

0 commit comments

Comments
 (0)