44
55using System ;
66using System . Collections . Immutable ;
7+ using System . Diagnostics . CodeAnalysis ;
78using System . Linq ;
89using ILLink . Shared ;
910using Microsoft . CodeAnalysis ;
@@ -116,7 +117,7 @@ void CheckStaticConstructors (OperationAnalysisContext operationContext,
116117 ImmutableArray < IMethodSymbol > staticConstructors )
117118 {
118119 foreach ( var staticConstructor in staticConstructors ) {
119- if ( staticConstructor . HasAttribute ( RequiresAttributeName ) && TryGetRequiresAttribute ( staticConstructor , out AttributeData ? requiresAttribute ) )
120+ if ( staticConstructor . HasAttribute ( RequiresAttributeName ) && TryGetRequiresAttribute ( staticConstructor , out var requiresAttribute ) )
120121 ReportRequiresDiagnostic ( operationContext , staticConstructor , requiresAttribute ) ;
121122 }
122123 }
@@ -149,7 +150,7 @@ void CheckCalledMember (
149150 while ( member is IMethodSymbol method && method . OverriddenMethod != null && SymbolEqualityComparer . Default . Equals ( method . ReturnType , method . OverriddenMethod . ReturnType ) )
150151 member = method . OverriddenMethod ;
151152
152- if ( TryGetRequiresAttribute ( member , out AttributeData ? requiresAttribute ) ) {
153+ if ( TryGetRequiresAttribute ( member , out var requiresAttribute ) ) {
153154 ReportRequiresDiagnostic ( operationContext , member , requiresAttribute ) ;
154155 }
155156 }
@@ -227,7 +228,7 @@ private static ISymbol FindContainingSymbol (OperationAnalysisContext operationC
227228 /// <param name="operationContext">Analyzer operation context to be able to report the diagnostic.</param>
228229 /// <param name="member">Information about the member that generated the diagnostic.</param>
229230 /// <param name="requiresAttribute">Requires attribute data to print attribute arguments.</param>
230- private void ReportRequiresDiagnostic ( OperationAnalysisContext operationContext , ISymbol member , AttributeData ? requiresAttribute )
231+ private void ReportRequiresDiagnostic ( OperationAnalysisContext operationContext , ISymbol member , AttributeData requiresAttribute )
231232 {
232233 var message = GetMessageFromAttribute ( requiresAttribute ) ;
233234 var url = GetUrlFromAttribute ( requiresAttribute ) ;
@@ -250,7 +251,7 @@ private void ReportMismatchInAttributesDiagnostic (SymbolAnalysisContext symbolA
250251
251252 private bool HasMismatchingAttributes ( ISymbol member1 , ISymbol member2 ) => member1 . HasAttribute ( RequiresAttributeName ) ^ member2 . HasAttribute ( RequiresAttributeName ) ;
252253
253- protected abstract string GetMessageFromAttribute ( AttributeData ? requiresAttribute ) ;
254+ protected abstract string GetMessageFromAttribute ( AttributeData requiresAttribute ) ;
254255
255256 private string GetUrlFromAttribute ( AttributeData ? requiresAttribute )
256257 {
@@ -264,7 +265,7 @@ private string GetUrlFromAttribute (AttributeData? requiresAttribute)
264265 /// <param name="member">Symbol of the member to search attribute.</param>
265266 /// <param name="requiresAttribute">Output variable in case of matching Requires attribute.</param>
266267 /// <returns>True if the member contains a Requires attribute; otherwise, returns false.</returns>
267- private bool TryGetRequiresAttribute ( ISymbol member , out AttributeData ? requiresAttribute )
268+ private bool TryGetRequiresAttribute ( ISymbol member , [ NotNullWhen ( returnValue : true ) ] out AttributeData ? requiresAttribute )
268269 {
269270 requiresAttribute = null ;
270271 foreach ( var _attribute in member . GetAttributes ( ) ) {
0 commit comments