Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>2022-10-25 20:42:21 +0300
committerGitHub <noreply@github.com>2022-10-25 20:42:21 +0300
commitc0bd2080670407e7681c26aadb4745d0b7c03e7c (patch)
tree25582fa374f84bc5a694f95d443d63d56c2dcfc0
parentd8ca185cf241d60182183ebe9740e36a23ac5b97 (diff)
Change analyzer versions such that the repo can be built with .NET 7 RC2 SDK (#3077)
Change analyzer versions such that the repo can be built with .NET 7 RC2 SDK. - Took the versions from dotnet/runtime. - Remove CheckAttributeInstantiation method since is no longer necessary - Remove global attributes since they are no longer necessary - Workaround the fact that compiler injects System.Runtime.CompilerServices.RefSafetyRulesAttribute into every assembly to describe the language version Co-authored-by: tlakollo <tlakaelel_axayakatl@outlook.com>
-rw-r--r--eng/Analyzers.props1
-rw-r--r--eng/Versions.props3
-rw-r--r--eng/ilasm.ilproj2
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs32
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs2
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/RequiresDynamicCodeAnalyzerTests.cs2
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs2
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/UnconditionalSuppressMessageCodeFixTests.cs2
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs10
9 files changed, 18 insertions, 38 deletions
diff --git a/eng/Analyzers.props b/eng/Analyzers.props
index 37816d62c..facf033c3 100644
--- a/eng/Analyzers.props
+++ b/eng/Analyzers.props
@@ -2,6 +2,7 @@
<ItemGroup Condition="'$(RunAnalyzers)' == 'true'">
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisVersion)" PrivateAssets="all" IsImplicitlyDefined="true" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(MicrosoftCodeAnalysisCSharpCodeStyleVersion)" PrivateAssets="all" />
+ <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="$(MicrosoftCodeAnalysisNetAnalyzersVersion)" PrivateAssets="all" />
<!-- <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.205" PrivateAssets="all" /> -->
</ItemGroup>
diff --git a/eng/Versions.props b/eng/Versions.props
index b2c170f53..6ad4820a8 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -21,10 +21,11 @@
<MicrosoftDotNetApiCompatVersion>8.0.0-beta.22520.1</MicrosoftDotNetApiCompatVersion>
<MicrosoftDotNetCodeAnalysisVersion>6.0.0-beta.21271.1</MicrosoftDotNetCodeAnalysisVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
- <MicrosoftCodeAnalysisVersion>4.4.0-1.final</MicrosoftCodeAnalysisVersion>
+ <MicrosoftCodeAnalysisVersion>4.5.0-1.22517.9</MicrosoftCodeAnalysisVersion>
<MicrosoftNetCompilersToolsetVersion>$(MicrosoftCodeAnalysisVersion)</MicrosoftNetCompilersToolsetVersion>
<MicrosoftCodeAnalysisCSharpAnalyzerTestingXunitVersion>1.0.1-beta1.*</MicrosoftCodeAnalysisCSharpAnalyzerTestingXunitVersion>
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.2</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
+ <MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22513.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftILVerificationVersion>7.0.0-preview.7.22375.6</MicrosoftILVerificationVersion>
<!-- This controls the version of the cecil package, or the version of cecil in the project graph
when we build the cecil submodule. The reference assembly package will depend on this version of cecil.
diff --git a/eng/ilasm.ilproj b/eng/ilasm.ilproj
index 3a11b2bfe..b13fc4042 100644
--- a/eng/ilasm.ilproj
+++ b/eng/ilasm.ilproj
@@ -4,7 +4,7 @@
project. -->
<PropertyGroup>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<Target Name="CopyILAsmTool" DependsOnTargets="ResolveIlasmToolPaths" Condition="'$(MonoBuild)' == ''">
diff --git a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
index 893dbeeca..2922c51ca 100644
--- a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
+++ b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
@@ -47,19 +47,11 @@ namespace ILLink.RoslynAnalyzer
if (methodSymbol.IsStaticConstructor () && methodSymbol.HasAttribute (RequiresAttributeName))
ReportRequiresOnStaticCtorDiagnostic (symbolAnalysisContext, methodSymbol);
CheckMatchingAttributesInOverrides (symbolAnalysisContext, methodSymbol);
- CheckAttributeInstantiation (symbolAnalysisContext, methodSymbol);
- foreach (var typeParameter in methodSymbol.TypeParameters)
- CheckAttributeInstantiation (symbolAnalysisContext, typeParameter);
-
}, SymbolKind.Method);
context.RegisterSymbolAction (symbolAnalysisContext => {
var typeSymbol = (INamedTypeSymbol) symbolAnalysisContext.Symbol;
CheckMatchingAttributesInInterfaces (symbolAnalysisContext, typeSymbol);
- CheckAttributeInstantiation (symbolAnalysisContext, typeSymbol);
- foreach (var typeParameter in typeSymbol.TypeParameters)
- CheckAttributeInstantiation (symbolAnalysisContext, typeParameter);
-
}, SymbolKind.NamedType);
@@ -68,8 +60,6 @@ namespace ILLink.RoslynAnalyzer
if (AnalyzerDiagnosticTargets.HasFlag (DiagnosticTargets.Property)) {
CheckMatchingAttributesInOverrides (symbolAnalysisContext, propertySymbol);
}
-
- CheckAttributeInstantiation (symbolAnalysisContext, propertySymbol);
}, SymbolKind.Property);
context.RegisterSymbolAction (symbolAnalysisContext => {
@@ -77,15 +67,8 @@ namespace ILLink.RoslynAnalyzer
if (AnalyzerDiagnosticTargets.HasFlag (DiagnosticTargets.Event)) {
CheckMatchingAttributesInOverrides (symbolAnalysisContext, eventSymbol);
}
-
- CheckAttributeInstantiation (symbolAnalysisContext, eventSymbol);
}, SymbolKind.Event);
- context.RegisterSymbolAction (symbolAnalysisContext => {
- var fieldSymbol = (IFieldSymbol) symbolAnalysisContext.Symbol;
- CheckAttributeInstantiation (symbolAnalysisContext, fieldSymbol);
- }, SymbolKind.Field);
-
context.RegisterOperationAction (operationContext => {
var methodInvocation = (IInvocationOperation) operationContext.Operation;
CheckCalledMember (operationContext, methodInvocation.TargetMethod, incompatibleMembers);
@@ -205,21 +188,6 @@ namespace ILLink.RoslynAnalyzer
foreach (var extraSymbolAction in ExtraSymbolActions)
context.RegisterSymbolAction (extraSymbolAction.Action, extraSymbolAction.SymbolKind);
- void CheckAttributeInstantiation (
- SymbolAnalysisContext symbolAnalysisContext,
- ISymbol symbol)
- {
- if (symbol.IsInRequiresScope (RequiresAttributeName))
- return;
-
- foreach (var attr in symbol.GetAttributes ()) {
- if (attr.AttributeConstructor?.DoesMemberRequire (RequiresAttributeName, out var requiresAttribute) == true) {
- symbolAnalysisContext.ReportDiagnostic (Diagnostic.Create (RequiresDiagnosticRule,
- symbol.Locations[0], attr.AttributeConstructor.GetDisplayName (), GetMessageFromAttribute (requiresAttribute), GetUrlFromAttribute (requiresAttribute)));
- }
- }
- }
-
void CheckCalledMember (
OperationAnalysisContext operationContext,
ISymbol member,
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
index cdc94089f..6d4db46a4 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresAssemblyFilesAnalyzerTests.cs
@@ -620,7 +620,7 @@ build_property.{MSBuildPropertyOptionNames.EnableSingleFileAnalyzer} = true")));
[RequiresAssemblyFiles("Calls Wrapper()")]
Action M2()
{
- [global::System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute("Calls C.M1()")] void Wrapper () => M1();
+ [RequiresAssemblyFiles("Calls C.M1()")] void Wrapper () => M1();
return Wrapper;
}
}
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresDynamicCodeAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresDynamicCodeAnalyzerTests.cs
index 2ed2be672..ef8203401 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/RequiresDynamicCodeAnalyzerTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresDynamicCodeAnalyzerTests.cs
@@ -200,7 +200,7 @@ build_property.{MSBuildPropertyOptionNames.EnableAotAnalyzer} = true")));
[RequiresDynamicCode("Calls Wrapper()")]
Action M2()
{
- [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Calls C.M1()")] void Wrapper () => M1();
+ [RequiresDynamicCode("Calls C.M1()")] void Wrapper () => M1();
return Wrapper;
}
}
diff --git a/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs b/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
index 64dbdacfe..12f839003 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/RequiresUnreferencedCodeAnalyzerTests.cs
@@ -236,7 +236,7 @@ build_property.{MSBuildPropertyOptionNames.EnableTrimAnalyzer} = true")));
[RequiresUnreferencedCode("Calls Wrapper()")]
Action M2()
{
- [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute("Calls C.M1()")] void Wrapper () => M1();
+ [RequiresUnreferencedCode("Calls C.M1()")] void Wrapper () => M1();
return Wrapper;
}
}
diff --git a/test/ILLink.RoslynAnalyzer.Tests/UnconditionalSuppressMessageCodeFixTests.cs b/test/ILLink.RoslynAnalyzer.Tests/UnconditionalSuppressMessageCodeFixTests.cs
index 4a9c2cf07..c59a2763f 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/UnconditionalSuppressMessageCodeFixTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/UnconditionalSuppressMessageCodeFixTests.cs
@@ -389,7 +389,7 @@ public class C
Action M2()
{
- [global::System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute(""Trimming"", ""IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code"", Justification = ""<Pending>"")] void Wrapper () => M1();
+ [UnconditionalSuppressMessage(""Trimming"", ""IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code"", Justification = ""<Pending>"")] void Wrapper () => M1();
return Wrapper;
}
}";
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
index 12f502b60..41210172f 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
@@ -49,6 +49,11 @@ namespace Mono.Linker.Tests.TestCasesRunner
return s.FullName;
}), StringComparer.Ordinal);
+ // Workaround for compiler injected attribute to describe the language version
+ linkedMembers.Remove ("System.Void Microsoft.CodeAnalysis.EmbeddedAttribute::.ctor()");
+ linkedMembers.Remove ("System.Int32 System.Runtime.CompilerServices.RefSafetyRulesAttribute::Version");
+ linkedMembers.Remove ("System.Void System.Runtime.CompilerServices.RefSafetyRulesAttribute::.ctor(System.Int32)");
+
var membersToAssert = originalAssembly.MainModule.Types;
foreach (var originalMember in membersToAssert) {
if (originalMember is TypeDefinition td) {
@@ -91,6 +96,10 @@ namespace Mono.Linker.Tests.TestCasesRunner
protected virtual void VerifyTypeDefinition (TypeDefinition original, TypeDefinition linked)
{
+ // Workaround for compiler injected attribute to describe the language version
+ verifiedGeneratedTypes.Add ("Microsoft.CodeAnalysis.EmbeddedAttribute");
+ verifiedGeneratedTypes.Add ("System.Runtime.CompilerServices.RefSafetyRulesAttribute");
+
if (linked != null && verifiedGeneratedTypes.Contains (linked.FullName))
return;
@@ -839,6 +848,7 @@ namespace Mono.Linker.Tests.TestCasesRunner
case "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute":
case "System.Runtime.CompilerServices.CompilerGeneratedAttribute":
case "System.Runtime.CompilerServices.IsReadOnlyAttribute":
+ case "System.Runtime.CompilerServices.RefSafetyRulesAttribute":
continue;
// When mcs is used to compile the test cases, backing fields end up with this attribute on them