Skip to content

Commit 122d113

Browse files
inikulshinIlya Nikulshin
andauthored
Bump Microsoft.CodeAnalysis.Analyzers from 3.3.4 to 3.11.0 (with code fixes) (#362)
Bump Microsoft.CodeAnalysis.Analyzers from 3.3.4 to 3.11.0 Co-authored-by: Ilya Nikulshin <[email protected]>
1 parent dc409d9 commit 122d113

File tree

3 files changed

+102
-104
lines changed

3 files changed

+102
-104
lines changed

Source/EasyNetQ.Management.Client.ExtensionsGenerator/EasyNetQ.Management.Client.ExtensionsGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
15-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
15+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
1616
<PackageReference Include="PolySharp" Version="1.14.1">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

Source/EasyNetQ.Management.Client.ExtensionsGenerator/ExtensionsGenerator.cs

Lines changed: 99 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -5,124 +5,120 @@
55
namespace EasyNetQ.Management.Client.ExtensionsGenerator;
66

77
[Generator]
8-
public class ExtensionsGenerator : ISourceGenerator
8+
public class ExtensionsGenerator : IIncrementalGenerator
99
{
10-
public void Execute(GeneratorExecutionContext context)
10+
public void Initialize(IncrementalGeneratorInitializationContext context)
1111
{
12-
var compilation = context.Compilation;
12+
// if (!System.Diagnostics.Debugger.IsAttached)
13+
// {
14+
// System.Diagnostics.Debugger.Launch();
15+
// }
1316

14-
string typeName = "EasyNetQ.Management.Client.IManagementClient";
15-
string typeExtensionsName = $"{typeName}Extensions";
17+
context.RegisterSourceOutput(context.CompilationProvider, (context, compilation) =>
18+
{
19+
string typeName = "EasyNetQ.Management.Client.IManagementClient";
20+
string typeExtensionsName = $"{typeName}Extensions";
1621

17-
var typeNames = new List<string> { typeName, typeExtensionsName };
18-
var types = typeNames.Select(tn => compilation.GetTypeByMetadataName(tn) ?? throw new KeyNotFoundException(tn));
22+
var typeNames = new List<string> { typeName, typeExtensionsName };
23+
var types = typeNames.Select(tn => compilation.GetTypeByMetadataName(tn) ?? throw new KeyNotFoundException(tn));
1924

20-
Dictionary<string, CompilationUnitSyntax> compilationUnits = new();
25+
Dictionary<string, CompilationUnitSyntax> compilationUnits = new();
2126

22-
var thisParameter = "this IManagementClient client".GetParameterSyntax();
23-
QualifiedNameSyntax extensionsClassName = (SyntaxFactory.ParseTypeName(typeExtensionsName) as QualifiedNameSyntax)!;
27+
var thisParameter = "this IManagementClient client".GetParameterSyntax();
28+
QualifiedNameSyntax extensionsClassName = (SyntaxFactory.ParseTypeName(typeExtensionsName) as QualifiedNameSyntax)!;
2429

25-
{
26-
var fileScopedNamespaceDeclaration = SyntaxFactory.FileScopedNamespaceDeclaration(extensionsClassName.Left)
27-
.WithLeadingTrivia(SyntaxFactory.Trivia(SyntaxFactory.NullableDirectiveTrivia(SyntaxFactory.Token(SyntaxKind.EnableKeyword), true)));
28-
29-
foreach (var t in types)
3030
{
31-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
32-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
33-
("string vhostName", "Vhost vhost", "vhost.Name")
34-
);
35-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
36-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
37-
("string vhostName", null, "exchange.Vhost"),
38-
("string exchangeName", "ExchangeName exchange", "exchange.Name")
39-
);
40-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
41-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
42-
("string vhostName", null, "queue.Vhost"),
43-
("string queueName", "QueueName queue", "queue.Name")
44-
);
45-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
46-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
47-
("string vhostName", null, "exchange.Vhost"),
48-
("string exchangeName", "ExchangeName exchange", "exchange.Name"),
49-
("string queueName", "QueueName queue", "queue.Name")
50-
);
51-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
52-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
53-
("string vhostName", null, "sourceExchange.Vhost"),
54-
("string sourceExchangeName", "ExchangeName sourceExchange", "sourceExchange.Name"),
55-
("string destinationExchangeName", "ExchangeName destinationExchange", "destinationExchange.Name")
56-
);
57-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
58-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
59-
("string connectionName", "Connection connection", "connection.Name")
60-
);
61-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
62-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
63-
("string userName", "User user", "user.Name")
64-
);
65-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
66-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
67-
("string vhostName", "Vhost vhost", "vhost.Name"),
68-
("string userName", "User user", "user.Name")
69-
);
70-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
71-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
72-
("string componentName", null, "parameter.Component"),
73-
("string vhostName", null, "parameter.Vhost"),
74-
("string parameterName", "Parameter parameter", "parameter.Name")
75-
);
76-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
77-
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
78-
("string componentName", null, "parameter.Component"),
79-
("string vhostName", null, "parameter.Vhost"),
80-
("string parameterName", null, "parameter.Name"),
81-
("object parameterValue", "Parameter parameter", "parameter.Value")
82-
);
31+
var fileScopedNamespaceDeclaration = SyntaxFactory.FileScopedNamespaceDeclaration(extensionsClassName.Left)
32+
.WithLeadingTrivia(SyntaxFactory.Trivia(SyntaxFactory.NullableDirectiveTrivia(SyntaxFactory.Token(SyntaxKind.EnableKeyword), true)));
33+
34+
foreach (var t in types)
35+
{
36+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
37+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
38+
("string vhostName", "Vhost vhost", "vhost.Name")
39+
);
40+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
41+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
42+
("string vhostName", null, "exchange.Vhost"),
43+
("string exchangeName", "ExchangeName exchange", "exchange.Name")
44+
);
45+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
46+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
47+
("string vhostName", null, "queue.Vhost"),
48+
("string queueName", "QueueName queue", "queue.Name")
49+
);
50+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
51+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
52+
("string vhostName", null, "exchange.Vhost"),
53+
("string exchangeName", "ExchangeName exchange", "exchange.Name"),
54+
("string queueName", "QueueName queue", "queue.Name")
55+
);
56+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
57+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
58+
("string vhostName", null, "sourceExchange.Vhost"),
59+
("string sourceExchangeName", "ExchangeName sourceExchange", "sourceExchange.Name"),
60+
("string destinationExchangeName", "ExchangeName destinationExchange", "destinationExchange.Name")
61+
);
62+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
63+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
64+
("string connectionName", "Connection connection", "connection.Name")
65+
);
66+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
67+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
68+
("string userName", "User user", "user.Name")
69+
);
70+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
71+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
72+
("string vhostName", "Vhost vhost", "vhost.Name"),
73+
("string userName", "User user", "user.Name")
74+
);
75+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
76+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
77+
("string componentName", null, "parameter.Component"),
78+
("string vhostName", null, "parameter.Vhost"),
79+
("string parameterName", "Parameter parameter", "parameter.Name")
80+
);
81+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
82+
.AddReplacementExtensionsClass(extensionsClassName, t, thisParameter,
83+
("string componentName", null, "parameter.Component"),
84+
("string vhostName", null, "parameter.Vhost"),
85+
("string parameterName", null, "parameter.Name"),
86+
("object parameterValue", "Parameter parameter", "parameter.Value")
87+
);
88+
}
89+
90+
var compilationUnit = SyntaxFactory.CompilationUnit()
91+
.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("EasyNetQ.Management.Client.Model")))
92+
.AddMembers(fileScopedNamespaceDeclaration)
93+
.NormalizeWhitespace(eol: "\n");
94+
95+
compilationUnits[$"{extensionsClassName.Right}Replacement"] = compilationUnit;
96+
97+
compilation = compilation.AddSyntaxTrees(compilationUnit.SyntaxTree);
8398
}
8499

85-
var compilationUnit = SyntaxFactory.CompilationUnit()
86-
.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("EasyNetQ.Management.Client.Model")))
87-
.AddMembers(fileScopedNamespaceDeclaration)
88-
.NormalizeWhitespace(eol: "\n");
100+
{
101+
var fileScopedNamespaceDeclaration = SyntaxFactory.FileScopedNamespaceDeclaration(extensionsClassName.Left)
102+
.WithLeadingTrivia(SyntaxFactory.Trivia(SyntaxFactory.NullableDirectiveTrivia(SyntaxFactory.Token(SyntaxKind.EnableKeyword), true)));
89103

90-
compilationUnits[$"{extensionsClassName.Right}Replacement"] = compilationUnit;
104+
foreach (var t in types)
105+
{
106+
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
107+
.AddSyncExtensionsClass(extensionsClassName, t, thisParameter);
108+
}
91109

92-
compilation = compilation.AddSyntaxTrees(compilationUnit.SyntaxTree);
93-
}
110+
var compilationUnit = SyntaxFactory.CompilationUnit()
111+
.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("EasyNetQ.Management.Client.Model")))
112+
.AddMembers(fileScopedNamespaceDeclaration)
113+
.NormalizeWhitespace(eol: "\n");
94114

95-
{
96-
var fileScopedNamespaceDeclaration = SyntaxFactory.FileScopedNamespaceDeclaration(extensionsClassName.Left)
97-
.WithLeadingTrivia(SyntaxFactory.Trivia(SyntaxFactory.NullableDirectiveTrivia(SyntaxFactory.Token(SyntaxKind.EnableKeyword), true)));
115+
compilationUnits[$"{extensionsClassName.Right}Sync"] = compilationUnit;
116+
}
98117

99-
foreach (var t in types)
118+
foreach (var kvpair in compilationUnits)
100119
{
101-
fileScopedNamespaceDeclaration = fileScopedNamespaceDeclaration
102-
.AddSyncExtensionsClass(extensionsClassName, t, thisParameter);
120+
context.AddSource($"{kvpair.Key}.g.cs", kvpair.Value.ToString());
103121
}
104-
105-
var compilationUnit = SyntaxFactory.CompilationUnit()
106-
.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("EasyNetQ.Management.Client.Model")))
107-
.AddMembers(fileScopedNamespaceDeclaration)
108-
.NormalizeWhitespace(eol: "\n");
109-
110-
compilationUnits[$"{extensionsClassName.Right}Sync"] = compilationUnit;
111-
}
112-
113-
foreach (var kvpair in compilationUnits)
114-
{
115-
context.AddSource($"{kvpair.Key}.g.cs", kvpair.Value.ToString());
116-
}
117-
}
118-
119-
public void Initialize(GeneratorInitializationContext context)
120-
{
121-
// No initialization required for this one
122-
123-
// if (!System.Diagnostics.Debugger.IsAttached)
124-
// {
125-
// System.Diagnostics.Debugger.Launch();
126-
// }
122+
});
127123
}
128124
}

Source/EasyNetQ.Management.Client/EasyNetQ.Management.Client.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<ImplicitUsings>enable</ImplicitUsings>
4040
<MinVerTagPrefix>v</MinVerTagPrefix>
4141
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
42+
43+
<EmitCompilerGeneratedFiles Condition="'$(TargetFramework)' == 'netstandard2.0' AND '$(Configuration)' == 'Debug'">true</EmitCompilerGeneratedFiles>
4244
</PropertyGroup>
4345

4446
<ItemGroup>

0 commit comments

Comments
 (0)