Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 /// <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));
 }
Ejemplo n.º 3
0
 public UnresolvedEntitySet(string name, IEdmEntityContainer container, EdmLocation location)
     : base(name, container, new[] { new EdmError(location, EdmErrorCode.BadUnresolvedEntitySet, Edm.Strings.Bad_UnresolvedEntitySet(name)) })
 {
 }
Ejemplo n.º 4
0
 public UnresolvedFunction(string qualifiedName, string errorMessage, EdmLocation location) 
     : base(qualifiedName, errorMessage, location)
 {
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
 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));
     }
 }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 public UnresolvedPrimitiveType(string qualifiedName, EdmLocation location)
     : base(qualifiedName, EdmPrimitiveTypeKind.None, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedPrimitiveType, Edm.Strings.Bad_UnresolvedPrimitiveType(qualifiedName)) })
 {
 }
Ejemplo n.º 10
0
 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()));
     }
 }
Ejemplo n.º 11
0
 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())) })
 {
 }
Ejemplo n.º 13
0
 public UnresolvedProperty(IEdmStructuredType declaringType, string name, EdmLocation location)
     : base(declaringType, name, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedProperty, Edm.Strings.Bad_UnresolvedProperty(name)) })
 {
 }
Ejemplo n.º 14
0
 /// <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)) })
 {
 }
Ejemplo n.º 17
0
 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);
 }
Ejemplo n.º 18
0
        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;
        }
Ejemplo n.º 19
0
 public CyclicEntityType(string qualifiedName, EdmLocation location)
     : base(qualifiedName, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicEntity, Edm.Strings.Bad_CyclicEntity(qualifiedName)) })
 {
 }
Ejemplo n.º 20
0
 public UnresolvedEntityType(string qualifiedName, EdmLocation location)
     : base(qualifiedName, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedEntityType, Edm.Strings.Bad_UnresolvedEntityType(qualifiedName)) })
 { 
 }
Ejemplo n.º 21
0
 public CyclicEntityContainer(string name, EdmLocation location)
     : base(name, new EdmError[] { new EdmError(location, EdmErrorCode.BadCyclicEntityContainer, Edm.Strings.Bad_CyclicEntityContainer(name)) })
 {
 }
Ejemplo n.º 22
0
 public UnresolvedLabeledElement(string label, EdmLocation location)
     : base(label, new EdmError[] { new EdmError(location, EdmErrorCode.BadUnresolvedLabeledElement, Edm.Strings.Bad_UnresolvedLabeledElement(label)) })
 { 
 }
Ejemplo n.º 23
0
        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;
        }