예제 #1
0
파일: MessageID.cs 프로젝트: belav/roslyn
 internal static CSDiagnosticInfo?GetFeatureAvailabilityDiagnosticInfo(
     this MessageID feature,
     CSharpCompilation compilation
     ) =>
 compilation.IsFeatureEnabled(feature)
       ? null
       : GetDisabledFeatureDiagnosticInfo(feature, compilation.LanguageVersion);
예제 #2
0
        private static DiagnosticInfo ReportNullableReferenceTypesIfNeeded(CSharpCompilation compilation, INonNullTypesContext nonNullTypesContext)
        {
            var featureID = MessageID.IDS_FeatureNullableReferenceTypes;

            if (!compilation.IsFeatureEnabled(featureID))
            {
                LanguageVersion availableVersion = compilation.LanguageVersion;
                LanguageVersion requiredVersion  = featureID.RequiredVersion();

                return(new CSDiagnosticInfo(availableVersion.GetErrorCode(), featureID.Localize(), new CSharpRequiredLanguageVersion(requiredVersion)));
            }
            else if (nonNullTypesContext.NonNullTypes != true)
            {
                return(new CSDiagnosticInfo(ErrorCode.WRN_MissingNonNullTypesContextForAnnotation));
            }

            return(null);
        }