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:
authorJackson Schuster <jschuster@microsoft.com>2021-12-09 21:43:20 +0300
committerJackson Schuster <jschuster@microsoft.com>2021-12-10 01:41:42 +0300
commit02d5a8c2fa2ead9bab2d14f00749010a37316802 (patch)
treefc0a3014dbfc37eb84f798b77c2f69eab93994c4
parent35e9b3b3aad4d5c252b653bb864ef3ecb8653c73 (diff)
Use ISymbol extension instead of Diagnostic Analyzer extension
-rw-r--r--src/ILLink.RoslynAnalyzer/COMAnalyzer.cs2
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs32
-rw-r--r--src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs (renamed from src/ILLink.RoslynAnalyzer/DiagnosticAnalyzerExtenstions.cs)11
3 files changed, 9 insertions, 36 deletions
diff --git a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
index f7586a94c..6f153aa76 100644
--- a/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
+++ b/src/ILLink.RoslynAnalyzer/COMAnalyzer.cs
@@ -40,7 +40,7 @@ namespace ILLink.RoslynAnalyzer
if (!targetMethod.HasAttribute (DllImportAttribute))
return;
- if (this.IsMemberInRequiresScope (operationContext.ContainingSymbol, RequiresUnreferencedCodeAttribute))
+ if (operationContext.ContainingSymbol.IsInRequiresScope (RequiresUnreferencedCodeAttribute))
return;
bool comDangerousMethod = IsComInterop (targetMethod.ReturnType);
diff --git a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
index 436845323..a49ceb439 100644
--- a/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
+++ b/src/ILLink.RoslynAnalyzer/RequiresAnalyzerBase.cs
@@ -220,7 +220,7 @@ namespace ILLink.RoslynAnalyzer
ISymbol containingSymbol = FindContainingSymbol (operationContext, AnalyzerDiagnosticTargets);
// Do not emit any diagnostic if caller is annotated with the attribute too.
- if (IsMemberInRequiresScope (containingSymbol))
+ if (containingSymbol.IsInRequiresScope(RequiresAttributeName))
return;
if (ReportSpecialIncompatibleMembersDiagnostic (operationContext, incompatibleMembers, member))
@@ -342,36 +342,6 @@ namespace ILLink.RoslynAnalyzer
return member1HasAttribute ^ member2HasAttribute;
}
- // TODO: Consider sharing with linker IsMethodInRequiresUnreferencedCodeScope method
- /// <summary>
- /// True if the source of a call is considered to be annotated with the Requires... attribute
- /// </summary>
- protected bool IsMemberInRequiresScope (ISymbol member)
- {
- containingSymbol.ContainingType.HasAttribute (RequiresAttributeName)) {
- return true;
- }
-
- // Check also for RequiresAttribute in the associated symbol
- if (containingSymbol is IMethodSymbol { AssociatedSymbol: { } associated } && associated.HasAttribute (RequiresAttributeName))
- return true;
-
- return false;
- }
-
- /// <summary>
- /// True if member of a call is considered to be annotated with the Requires... attribute. Primarily for property accessor declarations.
- /// </summary>
- /// <param name="containingSymbol">
- /// Symbol that is either an overriding member or an overriden/virtual member
- /// </param>
- protected bool IsOverrideMemberInRequiresScope (ISymbol member)
- {
- return member.HasAttribute (RequiresAttributeName)
- || (member is not ITypeSymbol
- && member.ContainingType.HasAttribute (RequiresAttributeName));
- }
-
// TODO: Consider sharing with linker DoesMethodRequireUnreferencedCode method
/// <summary>
/// True if the target of a call is considered to be annotated with the Requires... attribute
diff --git a/src/ILLink.RoslynAnalyzer/DiagnosticAnalyzerExtenstions.cs b/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs
index 390870d89..efe00031b 100644
--- a/src/ILLink.RoslynAnalyzer/DiagnosticAnalyzerExtenstions.cs
+++ b/src/ILLink.RoslynAnalyzer/RequiresISymbolExtensions.cs
@@ -1,14 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Text;
using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.Diagnostics;
namespace ILLink.RoslynAnalyzer
{
- static class RoslynDiagnosticAnalyzerExtenstions
+ public static class RequiresISymbolExtensions
{
- public static bool IsMemberInRequiresScope(this DiagnosticAnalyzer _, ISymbol member, string requiresAttribute)
+ // TODO: Consider sharing with linker IsMethodInRequiresUnreferencedCodeScope method
+ public static bool IsInRequiresScope (this ISymbol member, string requiresAttribute)
{
if (member is ISymbol containingSymbol) {
if (containingSymbol.HasAttribute (requiresAttribute)
@@ -23,5 +27,4 @@ namespace ILLink.RoslynAnalyzer
return false;
}
}
-
}