protected override DiagnosticInfo?ResolveInfo()
 {
     if (_possiblyNullableTypeSymbol.IsNullableType())
     {
         return(_possiblyNullableTypeSymbol.Type.OriginalDefinition.GetUseSiteInfo().DiagnosticInfo);
     }
     return(Binder.GetNullableUnconstrainedTypeParameterDiagnosticIfNecessary(_languageVersion, _possiblyNullableTypeSymbol));
 }
예제 #2
0
        protected override DiagnosticInfo ResolveInfo()
        {
            if (_possiblyNullableTypeSymbol.IsNullableType())
            {
                return(_possiblyNullableTypeSymbol.Type.OriginalDefinition.GetUseSiteDiagnostic());
            }
            else if (_possiblyNullableTypeSymbol.Type.IsTypeParameterDisallowingAnnotation())
            {
                return(new CSDiagnosticInfo(ErrorCode.ERR_NullableUnconstrainedTypeParameter));
            }

            return(null);
        }
예제 #3
0
        private bool ShouldAddNullableAnnotation(TypeWithAnnotations typeOpt)
        {
            if (!typeOpt.HasType)
            {
                return(false);
            }
            else if (format.MiscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier) &&
                     !typeOpt.IsNullableType() && !typeOpt.Type.IsValueType &&
                     typeOpt.NullableAnnotation.IsAnnotated())
            {
                return(true);
            }
            else if (format.CompilerInternalOptions.IncludesOption(SymbolDisplayCompilerInternalOptions.IncludeNonNullableTypeModifier) &&
                     !typeOpt.Type.IsValueType &&
                     typeOpt.NullableAnnotation.IsNotAnnotated() && !typeOpt.Type.IsTypeParameterDisallowingAnnotation())
            {
                return(true);
            }

            return(false);
        }