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

DiagnosticAnalyzerExtenstions.cs « ILLink.RoslynAnalyzer « src - github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 390870d8985761dccb44647c01d16120789c7fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;

namespace ILLink.RoslynAnalyzer
{
	static class RoslynDiagnosticAnalyzerExtenstions 
	{
		public static bool IsMemberInRequiresScope(this DiagnosticAnalyzer _, ISymbol member, string requiresAttribute)
		{
			if (member is ISymbol containingSymbol) {
				if (containingSymbol.HasAttribute (requiresAttribute)
					|| (containingSymbol is not ITypeSymbol &&
						 containingSymbol.ContainingType.HasAttribute (requiresAttribute))) {
					return true;
				}
			}
			if (member is IMethodSymbol { AssociatedSymbol: { } associated } && associated.HasAttribute (requiresAttribute))
				return true;

			return false;
		}
	}
	
}