public UnresolvedFunction(string qualifiedName, string errorMessage, EdmLocation location) : base(new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedFunction, errorMessage) }) { qualifiedName = qualifiedName ?? string.Empty; EdmUtil.TryGetNamespaceNameFromQualifiedName(qualifiedName, out this.namespaceName, out this.name); this.returnType = new BadTypeReference(new BadType(this.Errors), true); }
/// <summary> /// Register an error with the validation context. /// </summary> /// <param name="location">Location of the error.</param> /// <param name="errorCode">Value representing the error.</param> /// <param name="errorMessage">Message text discribing the error.</param> public void AddError(EdmLocation location, EdmErrorCode errorCode, string errorMessage) { this.AddError(new EdmError(location, errorCode, errorMessage)); }
public UnresolvedEntitySet(string name, IEdmEntityContainer container, EdmLocation location) : base(name, container, new[] { new EdmError(location, EdmErrorCode.BadUnresolvedEntitySet, Edm.Strings.Bad_UnresolvedEntitySet(name)) }) { }
public UnresolvedFunction(string qualifiedName, string errorMessage, EdmLocation location) : base(qualifiedName, errorMessage, location) { }
public UnresolvedParameter(IEdmFunctionBase declaringFunction, string name, EdmLocation location) : base(new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedParameter, Edm.Strings.Bad_UnresolvedParameter(name)) }) { this.name = name ?? string.Empty; this.declaringFunction = declaringFunction; }
private static bool TestNullabilityMatch(this IEdmTypeReference expressionType, IEdmTypeReference assertedType, EdmLocation location, out IEnumerable<EdmError> discoveredErrors) { if (!assertedType.IsNullable && expressionType.IsNullable) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.CannotAssertNullableTypeAsNonNullableType, Edm.Strings.EdmModel_Validator_Semantic_CannotAssertNullableTypeAsNonNullableType(expressionType.FullName())) }; return false; } discoveredErrors = Enumerable.Empty<EdmError>(); return true; }
private static void CheckForNameError(ValidationContext context, string name, EdmLocation location) { if (EdmUtil.IsNullOrWhiteSpaceInternal(name) || name.Length == 0) { context.AddError( location, EdmErrorCode.InvalidName, Strings.EdmModel_Validator_Syntactic_MissingName); } else if (name.Length > CsdlConstants.Max_NameLength) { context.AddError( location, EdmErrorCode.NameTooLong, Strings.EdmModel_Validator_Syntactic_EdmModel_NameIsTooLong(name)); } else if (!EdmUtil.IsValidUndottedName(name)) { context.AddError( location, EdmErrorCode.InvalidName, Strings.EdmModel_Validator_Syntactic_EdmModel_NameIsNotAllowed(name)); } }
private static bool TestTypeReferenceMatch(this IEdmTypeReference expressionType, IEdmTypeReference assertedType, EdmLocation location, bool matchExactly, out IEnumerable<EdmError> discoveredErrors) { if (!TestNullabilityMatch(expressionType, assertedType, location, out discoveredErrors)) { return false; } // A bad type reference matches anything (so as to avoid generating spurious errors). if (expressionType.IsBad()) { discoveredErrors = Enumerable.Empty<EdmError>(); return true; } return TestTypeMatch(expressionType.Definition, assertedType.Definition, location, matchExactly, out discoveredErrors); }
public UnresolvedPrimitiveType(string qualifiedName, EdmLocation location) : base(qualifiedName, EdmPrimitiveTypeKind.None, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedPrimitiveType, Edm.Strings.Bad_UnresolvedPrimitiveType(qualifiedName)) }) { }
private static void CheckForUnreacheableTypeError(ValidationContext context, IEdmSchemaType type, EdmLocation location) { IEdmType foundType = context.Model.FindType(type.FullName()); if (foundType is AmbiguousTypeBinding) { context.AddError( location, EdmErrorCode.BadAmbiguousElementBinding, Strings.EdmModel_Validator_Semantic_AmbiguousType(type.FullName())); } else if (!foundType.IsEquivalentTo(type)) { context.AddError( location, EdmErrorCode.BadUnresolvedType, Strings.EdmModel_Validator_Semantic_InaccessibleType(type.FullName())); } }
public UnresolvedEnumMember(string name, IEdmEnumType declaringType, EdmLocation location) : base(new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedEnumMember, Edm.Strings.Bad_UnresolvedEnumMember(name)) }) { this.name = name ?? string.Empty; this.declaringType = declaringType; }
public UnresolvedNavigationPropertyPath(IEdmEntityType startingType, string path, EdmLocation location) : base(startingType, path, new[] { new EdmError(location, EdmErrorCode.BadUnresolvedNavigationPropertyPath, Edm.Strings.Bad_UnresolvedNavigationPropertyPath(path, startingType.FullName())) }) { }
public UnresolvedProperty(IEdmStructuredType declaringType, string name, EdmLocation location) : base(declaringType, name, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedProperty, Edm.Strings.Bad_UnresolvedProperty(name)) }) { }
/// <summary> /// Initializes a new instance of the EdmError class. /// </summary> /// <param name="errorLocation">The location where the error occurred.</param> /// <param name="errorCode">An integer code representing the error.</param> /// <param name="errorMessage">A human readable message describing the error.</param> public EdmError(EdmLocation errorLocation, EdmErrorCode errorCode, string errorMessage) { this.ErrorLocation = errorLocation; this.ErrorCode = errorCode; this.ErrorMessage = errorMessage; }
public UnresolvedAssociationEnd(IEdmAssociation declaringAssociation, string role, EdmLocation location) : base(declaringAssociation, role, new EdmError[] { new EdmError(location, EdmErrorCode.BadNonComputableAssociationEnd, Edm.Strings.Bad_UncomputableAssociationEnd(role)) }) { }
public UnresolvedEntityContainer(string name, EdmLocation location) : base(name, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedEntityContainer, Edm.Strings.Bad_UnresolvedEntityContainer(name)) }) { }
public UnresolvedType(string qualifiedName, EdmLocation location) : base(new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedType, Edm.Strings.Bad_UnresolvedType(qualifiedName)) }) { qualifiedName = qualifiedName ?? string.Empty; EdmUtil.TryGetNamespaceNameFromQualifiedName(qualifiedName, out this.namespaceName, out this.name); }
private static bool TestTypeMatch(this IEdmType expressionType, IEdmType assertedType, EdmLocation location, bool matchExactly, out IEnumerable<EdmError> discoveredErrors) { if (matchExactly) { if (!expressionType.IsEquivalentTo(assertedType)) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.ExpressionNotValidForTheAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionNotValidForTheAssertedType) }; return false; } } else { // A bad type matches anything (so as to avoid generating spurious errors). if (expressionType.TypeKind == EdmTypeKind.None || expressionType.IsBad()) { discoveredErrors = Enumerable.Empty<EdmError>(); return true; } if (expressionType.TypeKind == EdmTypeKind.Primitive && assertedType.TypeKind == EdmTypeKind.Primitive) { IEdmPrimitiveType primitiveExpressionType = expressionType as IEdmPrimitiveType; IEdmPrimitiveType primitiveAssertedType = assertedType as IEdmPrimitiveType; if (!primitiveExpressionType.PrimitiveKind.PromotesTo(primitiveAssertedType.PrimitiveKind)) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindCannotPromoteToAssertedType(expressionType.ToTraceString(), assertedType.ToTraceString())) }; return false; } } else { if (!expressionType.IsOrInheritsFrom(assertedType)) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.ExpressionNotValidForTheAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionNotValidForTheAssertedType) }; return false; } } } discoveredErrors = Enumerable.Empty<EdmError>(); return true; }
public CyclicEntityType(string qualifiedName, EdmLocation location) : base(qualifiedName, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicEntity, Edm.Strings.Bad_CyclicEntity(qualifiedName)) }) { }
public UnresolvedEntityType(string qualifiedName, EdmLocation location) : base(qualifiedName, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedEntityType, Edm.Strings.Bad_UnresolvedEntityType(qualifiedName)) }) { }
public CyclicEntityContainer(string name, EdmLocation location) : base(name, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicEntityContainer, Edm.Strings.Bad_CyclicEntityContainer(name)) }) { }
public UnresolvedLabeledElement(string label, EdmLocation location) : base(label, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedLabeledElement, Edm.Strings.Bad_UnresolvedLabeledElement(label)) }) { }
private static bool TestTypeMatch(this IEdmTypeReference expressionType, IEdmTypeReference assertedType, EdmLocation location, out IEnumerable<EdmError> discoveredErrors) { if (!TestNullabilityMatch(expressionType, assertedType, location, out discoveredErrors)) { return false; } // A bad type matches anything (so as to avoid generating spurious errors). if (expressionType.TypeKind() == EdmTypeKind.None || expressionType.IsBad()) { discoveredErrors = Enumerable.Empty<EdmError>(); return true; } if (expressionType.IsPrimitive() && assertedType.IsPrimitive()) { if (!expressionType.PrimitiveKind().PromotesTo(assertedType.AsPrimitive().PrimitiveKind())) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.ExpressionPrimitiveKindNotValidForAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionPrimitiveKindCannotPromoteToAssertedType(expressionType.FullName(), assertedType.FullName())) }; return false; } } else { if (!expressionType.Definition.IsEquivalentTo(assertedType.Definition)) { discoveredErrors = new EdmError[] { new EdmError(location, EdmErrorCode.ExpressionNotValidForTheAssertedType, Edm.Strings.EdmModel_Validator_Semantic_ExpressionNotValidForTheAssertedType) }; return false; } } discoveredErrors = Enumerable.Empty<EdmError>(); return true; }