protected override bool ResultIsAlreadyCheckedByContractEnsures(IEnumerable <ContractEnsures> ensureAssertions, IDeclaredType methodReturnType) { // Ensures for enums should be available for System.Enum and for System.Enum? // thats why we should extract underlying type out of the nullable type. var returnType = methodReturnType.IsNullable() ? methodReturnType.GetNullableUnderlyingType() : methodReturnType; return(ensureAssertions .Any(e => e.ChecksForNotNull( pa => pa.With(x => x as ContractResultPredicateArgument) .With(x => x.ResultTypeName.FullName) == returnType.GetClrTypeName().FullName))); }
private void AppendDeclaredType([NotNull] IDeclaredType declaredType, QualifierDisplays expectedQualifierDisplay, Context context) { if (declaredType.IsNullable()) { IType underlyingType = declaredType.GetNullableUnderlyingType(); if (underlyingType != null) { AppendTypeWithoutModule(underlyingType, expectedQualifierDisplay, context); AppendText("?", _highlighterIdProvider.Operator); return; } } if (declaredType is IDynamicType) { AppendText("dynamic", _highlighterIdProvider.Keyword); return; } if (context.Options.UseTypeKeywords) { string typeKeyword = CSharpTypeFactory.GetTypeKeyword(declaredType.GetClrName()); if (typeKeyword != null) { AppendText(typeKeyword, _highlighterIdProvider.Keyword); return; } } else if (declaredType.IsVoid()) { AppendText("void", _highlighterIdProvider.Keyword); return; } ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement == null || !typeElement.IsValid()) { PsiLanguageType language = CSharpLanguage.Instance ?? (PsiLanguageType)UnknownLanguage.Instance; AppendText(declaredType.GetPresentableName(language), null); } else { AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedQualifierDisplay, context); } }
private void AppendDeclaredType([NotNull] IDeclaredType declaredType, NamespaceDisplays expectedNamespaceDisplay) { if (declaredType.IsNullable()) { IType underlyingType = declaredType.GetNullableUnderlyingType(); if (underlyingType != null) { AppendType(underlyingType, expectedNamespaceDisplay); AppendText("?", VsHighlightingAttributeIds.Operator); return; } } if (declaredType is IDynamicType) { AppendText("dynamic", VsHighlightingAttributeIds.Keyword); return; } if (_options.UseTypeKeywords) { string typeKeyword = CSharpTypeFactory.GetTypeKeyword(declaredType.GetClrName()); if (typeKeyword != null) { AppendText(typeKeyword, VsHighlightingAttributeIds.Keyword); return; } } else if (declaredType.IsVoid()) { AppendText("void", VsHighlightingAttributeIds.Keyword); return; } ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement == null || !typeElement.IsValid()) { AppendText(declaredType.GetPresentableName(UnknownLanguage.Instance), null); return; } AppendTypeElement(typeElement, declaredType.GetSubstitution(), expectedNamespaceDisplay); }
protected override bool ResultIsAlreadyCheckedByContractEnsures(IEnumerable<ContractEnsures> ensureAssertions, IDeclaredType methodReturnType) { // Ensures for enums should be available for System.Enum and for System.Enum? // thats why we should extract underlying type out of the nullable type. var returnType = methodReturnType.IsNullable() ? methodReturnType.GetNullableUnderlyingType() : methodReturnType; return ensureAssertions .Any(e => e.ChecksForNotNull( pa => pa.With(x => x as ContractResultPredicateArgument) .With(x => x.ResultTypeName.FullName) == returnType.GetClrTypeName().FullName)); }