// TODO: this feels fishy. EntityDesignModel does not have access to ErrorList // and this is the way to avoid taking the additional dependency. Figure out // a better way to log the error. public void LogUpdateModelWizardError(ErrorInfo errorInfo, string fileInfoPath) { if (LogUpdateModelWizardErrorAction != null) { LogUpdateModelWizardErrorAction(errorInfo, fileInfoPath); } }
internal override void Visit(IVisitable visitable) { var item = visitable as EFContainer; if (item == null) { return; } if (item.State != EFElementState.Normalized) { return; } try { item.Resolve(_artifactSet); } catch (Exception e) { // reset element state item.State = EFElementState.ResolveAttempted; string name = null; var nameable = item as EFNameableItem; if (nameable != null) { name = nameable.LocalName.Value; } else { var element = item.XObject as XElement; if (element != null) { name = element.Name.LocalName; } else { name = item.SemanticName; } } var message = string.Format(CultureInfo.CurrentCulture, Resources.ErrorResolvingItem, name, e.Message); var errorInfo = new ErrorInfo( ErrorInfo.Severity.ERROR, message, item, ErrorCodes.FATAL_RESOLVE_ERROR, ErrorClass.ResolveError); _artifactSet.AddError(errorInfo); } if (item.State != EFElementState.Resolved) { var efElement = item as EFElement; if (efElement != null) { _missedCount++; if (!_missed.Contains(efElement)) { _missed.Add(efElement); } } } }
/// <summary> /// Add a symbol to the global symbol table that maps to the passed in item. /// </summary> /// <param name="symbol"></param> /// <param name="item"></param> internal void AddSymbol(Symbol symbol, EFElement item) { if (!_symbolTable.ContainsKey(symbol)) { var list = new List<EFElement>(1); list.Add(item); _symbolTable.Add(symbol, list); } else { var current = LookupSymbol(symbol); if (current.Identity != item.Identity) { // duplicate symbol. Add the new item to the list _symbolTable[symbol].Add(item); // make it ready to display to the user var displayableSymbol = EFNormalizableItem.ConvertSymbolToExternal(symbol); // add an duplicate symbol error var msg = String.Format(CultureInfo.CurrentCulture, Resources.NORMALIZE_DUPLICATE_SYMBOL_DEFINED, displayableSymbol); var errorInfo = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, item, ErrorCodes.NORMALIZE_DUPLICATE_SYMBOL_DEFINED, ErrorClass.ResolveError); AddError(errorInfo); } } }
internal static ErrorTask CreateErrorTask(ErrorInfo errorInfo, IVsHierarchy hierarchy, uint itemID) { // errorInfo.Item can be null if the error came from CodeFirst return CreateErrorTask( errorInfo.ItemPath, errorInfo.Message, errorInfo.Item != null ? VSXmlModel.ConvertToVSTextSpan(errorInfo.Item.GetTextSpan()) : new TextSpan(), GetCategory(errorInfo), hierarchy, itemID); }
public void Code_first_ErrorInfo_initialized_correctly() { var edmxErrorInfo = new ErrorInfo(ErrorInfo.Severity.WARNING, "test", @"c:\project\model.edmx" , 17, ErrorClass.None); Assert.Equal(0, edmxErrorInfo.GetLineNumber()); Assert.Equal(0, edmxErrorInfo.GetColumnNumber()); Assert.False(edmxErrorInfo.IsError()); Assert.True(edmxErrorInfo.IsWarning()); Assert.False(edmxErrorInfo.IsInfo()); Assert.Equal(string.Format(Resources.Error_Message_With_Error_Code_Prefix, 17, "test"), edmxErrorInfo.Message); Assert.Same(null, edmxErrorInfo.Item); Assert.Equal(@"c:\project\model.edmx", edmxErrorInfo.ItemPath); Assert.Equal(17, edmxErrorInfo.ErrorCode); Assert.Equal(ErrorClass.None, edmxErrorInfo.ErrorClass); }
public void Edmx_ErrorInfo_initialized_correctly() { var mockEFObject = new Mock<EFObject>(); mockEFObject.Setup(o => o.GetLineNumber()).Returns(76); mockEFObject.Setup(o => o.GetColumnNumber()).Returns(12); mockEFObject.Setup(o => o.Uri).Returns(new Uri(@"c:\project\model.edmx")); var edmxErrorInfo = new ErrorInfo(ErrorInfo.Severity.ERROR, "test", mockEFObject.Object, 42, ErrorClass.Runtime_CSDL); Assert.Equal(76, edmxErrorInfo.GetLineNumber()); Assert.Equal(12, edmxErrorInfo.GetColumnNumber()); Assert.True(edmxErrorInfo.IsError()); Assert.False(edmxErrorInfo.IsWarning()); Assert.False(edmxErrorInfo.IsInfo()); Assert.Equal(string.Format(Resources.Error_Message_With_Error_Code_Prefix, 42, "test"), edmxErrorInfo.Message); Assert.Same(mockEFObject.Object, edmxErrorInfo.Item); Assert.Equal(@"c:\project\model.edmx", edmxErrorInfo.ItemPath); Assert.Equal(42, edmxErrorInfo.ErrorCode); Assert.Equal(ErrorClass.Runtime_CSDL, edmxErrorInfo.ErrorClass); }
internal static NormalizedName DefaultNameNormalizerForMSL(EFElement parent, string refName) { var model = MappingModel.GetMappingRoot(parent); string potentialAliasOrNamespacePart = null; string nonAliasOrNamespacePart = null; SeparateRefNameIntoParts(refName, out potentialAliasOrNamespacePart, out nonAliasOrNamespacePart); Symbol symbol = null; NormalizedName normalizedName = null; if (!string.IsNullOrEmpty(potentialAliasOrNamespacePart)) { // see if our type name starts with any of the defined aliases var startsWithAlias = false; foreach (var a in model.Aliases()) { if (potentialAliasOrNamespacePart.Equals(a.Key.Value, StringComparison.CurrentCultureIgnoreCase)) { if (a.State == EFElementState.Parsed) { // alias is only in a parsed state, skip for now and don't add an error // we'll end up looping around again later once its been resolved return new NormalizedName(new Symbol(refName), null, null, refName); } if (a.State != EFElementState.Resolved || a.Value.Status != BindingStatus.Known) { var msg = string.Format(CultureInfo.CurrentCulture, Resources.RESOLVE_UNRESOLVED_ALIAS, refName); var artifactSet = parent.Artifact.ModelManager.GetArtifactSet(parent.Artifact.Uri); var errorInfo = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, parent, ErrorCodes.RESOLVE_UNRESOLVED_ALIAS, ErrorClass.ResolveError); artifactSet.AddError(errorInfo); return new NormalizedName(new Symbol(String.Empty), null, null, refName); } // in the symbol replace alias with the full namespace symbol = new Symbol(a.Value.Target.Namespace.Value, nonAliasOrNamespacePart); normalizedName = new NormalizedName(symbol, a.Key.Value, null, nonAliasOrNamespacePart); startsWithAlias = true; break; } } if (startsWithAlias == false && model.Artifact.ConceptualModel() != null && model.Artifact.StorageModel() != null) { var conceptualNamespace = model.Artifact.ConceptualModel().Namespace.Value; var storageNamespace = model.Artifact.StorageModel().Namespace.Value; var currentNamespace = string.Empty; var convertIt = false; var startsWithConceptualNamespace = false; var startsWithStorageNamespace = false; if (potentialAliasOrNamespacePart.Equals(conceptualNamespace, StringComparison.CurrentCultureIgnoreCase)) { startsWithConceptualNamespace = true; } if (potentialAliasOrNamespacePart.Equals(storageNamespace, StringComparison.CurrentCultureIgnoreCase)) { startsWithStorageNamespace = true; } if (startsWithConceptualNamespace && startsWithStorageNamespace) { // in this case, the two namespaces start with the same thing and we got a match // on both; for example if there is pubsModel & pubsModel.Store and we are checking // on a string 'pubsModel.Store.Customer'; whichever is longer is the real one if (conceptualNamespace.Length > storageNamespace.Length) { currentNamespace = conceptualNamespace; convertIt = true; } else { currentNamespace = storageNamespace; convertIt = true; } } else if (startsWithConceptualNamespace) { currentNamespace = conceptualNamespace; convertIt = true; } else if (startsWithStorageNamespace) { currentNamespace = storageNamespace; convertIt = true; } if (convertIt) { // convert to our normalized name format symbol = new Symbol(currentNamespace, nonAliasOrNamespacePart); normalizedName = new NormalizedName(symbol, null, currentNamespace, nonAliasOrNamespacePart); } } } if (symbol == null) { // either there was no Alias or Namespace part or it didn't // match any of the known Aliases or Namespaces symbol = new Symbol(refName); normalizedName = new NormalizedName(symbol, null, null, refName); } return normalizedName; }
private static TaskErrorCategory GetCategory(ErrorInfo errorInfo) { if (errorInfo.IsError()) { return TaskErrorCategory.Error; } else if (errorInfo.IsInfo()) { return TaskErrorCategory.Message; } else if (errorInfo.IsWarning()) { return TaskErrorCategory.Warning; } else { return TaskErrorCategory.Error; } }
internal void ParseSingleEntityModelElement( XElement entityModelXElement, ref bool conceptualModelsProcessed, ref bool storageModelsProcessed, ref bool mappingsProcessed) { if (!CheckForCorrectNamespace(entityModelXElement, SchemaManager.GetEDMXNamespaceNames())) { return; } if (entityModelXElement.Name.LocalName == "ConceptualModels") { if (conceptualModelsProcessed) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, entityModelXElement.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); return; } conceptualModelsProcessed = true; ParseConceptualModels(entityModelXElement); } else if (entityModelXElement.Name.LocalName == "StorageModels") { if (storageModelsProcessed) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, entityModelXElement.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); return; } storageModelsProcessed = true; ParseStorageModels(entityModelXElement); } else if (entityModelXElement.Name.LocalName == "Mappings") { if (mappingsProcessed) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, entityModelXElement.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); return; } mappingsProcessed = true; ParseMappings(entityModelXElement); } else { var msg = String.Format(CultureInfo.CurrentCulture, Resources.UnexpectedElementMsg, entityModelXElement.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.UNEXPECTED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); return; } }
internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem) { // Conceptual EntityModel needs to create Conceptual EntityContainer objects if (elem.Name.LocalName == BaseEntityContainer.ElementName) { if (_entityContainers.Count > 0) { // multiple EntityContainers detected, report an error var msg = String.Format(CultureInfo.CurrentCulture, Resources.TOO_MANY_ENTITY_CONTAINER_ELEMENTS, Namespace.Value); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.TOO_MANY_ENTITY_CONTAINER_ELEMENTS, ErrorClass.ParseError); Artifact.AddParseErrorForObject(this, error); } var ec = new ConceptualEntityContainer(this, elem); _entityContainers.Add(ec); ec.Parse(unprocessedElements); } else if (elem.Name.LocalName == ComplexType.ElementName) { var complexType = new ComplexType(this, elem); _complexTypes.Add(complexType); complexType.Parse(unprocessedElements); } else if (elem.Name.LocalName == UsingElement.ElementName) { var use = new UsingElement(this, elem); _usings.Add(use); use.Parse(unprocessedElements); } else if (elem.Name.LocalName == EnumType.ElementName) { // Check if enumType that represents the XElement <see DoParse method> var enumType = ModelItemAnnotation.GetModelItem(elem) as EnumType; if (enumType == null || enumType.IsDisposed) { enumType = new EnumType(this, elem); _enumTypes.Add(enumType); enumType.Parse(unprocessedElements); } } else { return base.ParseSingleElement(unprocessedElements, elem); } return true; }
private void ProcessErrors(IList<EdmSchemaError> schemaErrors, Uri projectItemUri, EFArtifact artifact) { // since we will inevitably add *all* errors from the artifact set into the error list, we can easily // clear the entire error list here even though we just validate the CSDL. var errorList = ErrorListHelper.GetSingleDocErrorList(projectItemUri); if (errorList != null) { errorList.Clear(); } if (artifact == null) { Debug.Fail("Where is the artifact? We should have created it at least through the temporary model manager"); return; } // we have to remove both the RMV and SFG CSDL errors to prevent duplicates artifact.ArtifactSet.RemoveErrorsForArtifact(artifact, ErrorClass.Runtime_CSDL); // add all CSDL-based SFG errors to the artifact set if (schemaErrors.Count > 0) { foreach (var error in schemaErrors) { // construct an ErrorInfo with correct line/column number and add it to the artifact set. Note that the CodeGen EdmSchemaError line // refers to the line of the error inside the CSDL, so to get the line of the error in the edmx file we have to offset it by the line // number where the conceptual model begins. var edmxErrorLine = error.Line + artifact.ConceptualModel().GetLineNumber(); var efobject = artifact.FindEFObjectForLineAndColumn(edmxErrorLine, error.Column); var errorInfo = new ErrorInfo( GetErrorInfoSeverity(error), error.Message, efobject, error.ErrorCode, ErrorClass.Runtime_CSDL); artifact.ArtifactSet.AddError(errorInfo); } } // get all the ErrorInfos for this artifact and add it to the error list var artifactSet = artifact.ArtifactSet; Debug.Assert(artifactSet != null, "Where is the artifact set for this artifact?"); if (artifactSet != null) { var errors = artifactSet.GetArtifactOnlyErrors(artifact); if (errors.Count > 0) { // resolve the hierarchy and item id for adding to the error list var hierarchy = VSHelpers.GetVsHierarchy(ProjectItem.ContainingProject, Services.ServiceProvider); var itemId = VsUtils.GetProjectItemId(hierarchy, ProjectItem); Debug.Assert(hierarchy != null, "Why isn't there a hierarchy associated with this project item?"); Debug.Assert(itemId != VSConstants.VSITEMID_NIL, "There should be an item ID associated with this project item"); if (hierarchy != null && itemId != VSConstants.VSITEMID_NIL) { ErrorListHelper.AddErrorInfosToErrorList(errors, hierarchy, itemId); } } } }
internal void AddParseErrorForObject(EFObject obj, ErrorInfo errorInfo) { Debug.Assert(errorInfo.ErrorClass == ErrorClass.ParseError, "Unexpected error class added to EFObject"); Debug.Assert(errorInfo.Item == obj, "ErrorInfo for wrong object added to EFObject"); if (_errors == null) { _errors = new Dictionary<EFObject, ICollection<ErrorInfo>>(); } ICollection<ErrorInfo> errorCollection; if (!_errors.TryGetValue(obj, out errorCollection)) { errorCollection = new List<ErrorInfo>(); _errors.Add(obj, errorCollection); } errorCollection.Add(errorInfo); }
internal void AddParseErrorForObject(EFObject obj, string errorMessage, int errorCode) { var ei = new ErrorInfo(ErrorInfo.Severity.ERROR, errorMessage, obj, errorCode, ErrorClass.ParseError); AddParseErrorForObject(obj, ei); }
/// <summary> /// Helper method to log the VS warning message given the principal and dependent properties /// for which we could not find matches in the existing artifact /// </summary> private static void LogWarningMessageForReferentialConstraintProperties( string associationName, EntityType principalEntityType, EntityType dependentEntityType, List<string> unfoundPrincipalProperties, List<string> unfoundDependentProperties) { if (unfoundDependentProperties.Count > 0 || unfoundPrincipalProperties.Count > 0) { // log a warning to the VS error list. var propertyList = new StringBuilder(); var isFirst = true; foreach (var p in unfoundPrincipalProperties) { if (false == isFirst) { propertyList.Append(Resources.SeparatorCharacterForMultipleItemsInAnErrorMessage); } propertyList.Append(p); isFirst = false; } foreach (var p in unfoundDependentProperties) { if (false == isFirst) { propertyList.Append(Resources.SeparatorCharacterForMultipleItemsInAnErrorMessage); } propertyList.Append(p); isFirst = false; } var prinicpalEntityTypeName = principalEntityType.LocalName.Value; var dependentEntityTypeName = dependentEntityType.LocalName.Value; var s = String.Format( CultureInfo.CurrentCulture, Resources.UpdateFromDatabaseUnableToBringRefConstraint, associationName, prinicpalEntityTypeName, dependentEntityTypeName, propertyList); var errorMessageTarget = unfoundPrincipalProperties.Count > 0 ? principalEntityType : dependentEntityType; var errorInfo = new ErrorInfo( ErrorInfo.Severity.WARNING, s, errorMessageTarget, ErrorCodes.UPDATE_MODEL_FROM_DB_CANT_INCLUDE_REF_CONSTRAINT, ErrorClass.Escher_UpdateModelFromDB); HostContext.Instance.LogUpdateModelWizardError(errorInfo, errorMessageTarget.Uri.LocalPath); } }
private bool CheckForCorrectNamespace(XElement element, string[] expectedNamespace, bool addParseErrorOnFailure) { if (element == null || element.Name == null || element.Name.Namespace == null) { return false; } var foundMatch = false; foreach (var namespaceName in expectedNamespace) { if (element.Name.NamespaceName == namespaceName) { foundMatch = true; break; } } if (!foundMatch) { // add an error & return false. if (addParseErrorOnFailure) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.ModelParse_NonQualifiedElement, element.Name.LocalName); var error = new ErrorInfo(ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.NON_QUALIFIED_ELEMENT, ErrorClass.ParseError); AddParseErrorForObject(this, error); } return false; } return true; }
internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem) { if (elem.Name.LocalName == "Edmx") { if (!CheckForCorrectNamespace(elem, SchemaManager.GetEDMXNamespaceNames())) { return false; } var runtimeElementProcessed = false; var designerElementProcessed = false; foreach (var elem2 in elem.Elements()) { if (elem2.Name.LocalName == "Runtime") { if (!CheckForCorrectNamespace(elem2, SchemaManager.GetEDMXNamespaceNames())) { continue; } if (runtimeElementProcessed) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem2.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); continue; } runtimeElementProcessed = true; var conceptualModelsProcessed = false; var storageModelsProcessed = false; var mappingsProcessed = false; foreach (var elem3 in elem2.Elements()) { ParseSingleEntityModelElement( elem3, ref conceptualModelsProcessed, ref storageModelsProcessed, ref mappingsProcessed); } } else if (elem2.Name.LocalName == "Designer") { if (!CheckForCorrectNamespace(elem2, SchemaManager.GetEDMXNamespaceNames())) { continue; } if (designerElementProcessed) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem2.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); continue; } designerElementProcessed = true; ParseDesignerInfoRoot(elem2); } else if (elem2.Name.LocalName == "DataServices") { if (!CheckForCorrectNamespace(elem2, SchemaManager.GetEDMXNamespaceNames())) { continue; } _dataServicesNodePresent = true; var error = new ErrorInfo( ErrorInfo.Severity.WARNING, Resources.DataServicesNodeWarning, this, ErrorCodes.DATA_SERVICES_NODE_DETECTED, ErrorClass.ParseError); AddParseErrorForObject(this, error); } else { var msg = String.Format(CultureInfo.CurrentCulture, Resources.UnexpectedElementMsg, elem2.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.UNEXPECTED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); continue; } } return true; } else { var msg = String.Format(CultureInfo.CurrentCulture, Resources.UnexpectedElementMsg, elem.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.UNEXPECTED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); return false; } }
/// <summary> /// This method returns true if the passed-in error code is one that requires the document to be opened in the XML editor, /// with no designer. /// </summary> internal static bool IsOpenInEditorError(ErrorInfo errorInfo, EFArtifact artifact) { if ((errorInfo.ErrorClass & ErrorClass.Runtime_All) == 0) { return false; } var o = artifact.FindEFObjectForLineAndColumn(errorInfo.GetLineNumber(), errorInfo.GetColumnNumber()); if (errorInfo.ErrorCode == (int)MappingErrorCode.XmlSchemaValidationError && o is ModificationFunctionMapping) { // we don't trigger safe-mode for XSD errors on ModificationFunctionMapping, since these can be fixed in the designer return false; } if (errorInfo.ErrorCode == (int)ErrorCode.XmlError && o is ReferentialConstraintRole) { // we don't trigger safe-mode for XSD errors on referential constraint roles. This is so we can leave the RC // and the Role, even if it has no properties. return false; } if (errorInfo.ErrorCode == (int)MappingErrorCode.ConditionError && o is Condition) { // don't trigger safe-mode for errors based around condition validation return false; } if (errorInfo.ErrorCode == (int)ErrorCode.InvalidPropertyInRelationshipConstraint && o is ReferentialConstraint) { // don't trigger safe-mode for error about Principal not being exactly identical to the EntityType key, // since we can run into this problem just by adding new key Property to the EntityType that is Principal Role for some Referential Constraint return false; } if (errorInfo.ErrorCode == ErrorCodes.ESCHER_VALIDATOR_UNDEFINED_COMPLEX_PROPERTY_TYPE || (errorInfo.ErrorCode == (int)ErrorCode.NotInNamespace && o is ComplexConceptualProperty)) { // don't trigger safe-mode for underfined/deleted complex property types, the user should be able to fix the problem in the designer. return false; } if (errorInfo.ErrorCode == (int)ErrorCode.XmlError) { var navigationProperty = o as NavigationProperty; if (navigationProperty != null) { // we allow the user to have navigation properties not bound to any association via an AssociationEnd if the Name property is defined as it's still required. return string.IsNullOrEmpty(navigationProperty.LocalName.Value) /* invalid name */|| navigationProperty.Relationship.Status != BindingStatus.Undefined || navigationProperty.ToRole.Status != BindingStatus.Undefined || navigationProperty.FromRole.Status != BindingStatus.Undefined; } } return UnrecoverableRuntimeErrors.SchemaObjectModelErrorCodes.Any(c => c == (ErrorCode)errorInfo.ErrorCode) || UnrecoverableRuntimeErrors.StorageMappingErrorCodes.Any(c => c == (MappingErrorCode)errorInfo.ErrorCode); }
private void ParseConceptualModels(XElement conceptualModelsElement) { foreach (var elem in conceptualModelsElement.Elements()) { if (elem.Name.LocalName == BaseEntityModel.ElementName) { if (!CheckForCorrectNamespace(elem, SchemaManager.GetCSDLNamespaceNames())) { continue; } if (_conceptualEntityModel != null) { var msg = String.Format(CultureInfo.CurrentCulture, Resources.DuplicatedElementMsg, elem.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.DUPLICATED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); } else { CreateRuntimeModelRoot(elem); } } else { var msg = String.Format(CultureInfo.CurrentCulture, Resources.UnexpectedElementMsg, elem.Name.LocalName); var error = new ErrorInfo( ErrorInfo.Severity.ERROR, msg, this, ErrorCodes.UNEXPECTED_ELEMENT_ENCOUNTERED, ErrorClass.ParseError); AddParseErrorForObject(this, error); } } }
/// <summary> /// use this to add a resolve or semantic validation error. These are added to the EFArtifactSet, and not the EFArtifact /// because they occur in the context of other files in the set. /// Note that the ErrorInfo cannot contain an ErrorClass mask made up of multiple ErrorClass flags. /// </summary> internal virtual void AddError(ErrorInfo errorInfo) { Debug.Assert(errorInfo != null, "Unexpected null value passed into AddError()"); Debug.Assert(errorInfo.Item != null, "errorInfo had null Item"); Debug.Assert(errorInfo.Item.Artifact != null, "errorInfo.Item.Artifact was null"); Debug.Assert( Enum.GetName(typeof(ErrorClass), errorInfo.ErrorClass) != null, "The specified error class is not a value within the ErrorClass type"); Debug.Assert( Enum.GetValues(typeof(ErrorClass)) .Cast<uint>() .Where(v => !IsCompositeErrorClass(v) && v != 0) .Contains((uint)errorInfo.ErrorClass), "Unexpected ErrorClass of ErrorInfo; it should be a non-zero, non-composite (one and only 1 bit should be set)"); var errorClass2ErrorInfo = _artifacts2Errors[errorInfo.Item.Artifact]; ICollection<ErrorInfo> errors; if (!errorClass2ErrorInfo.TryGetValue(errorInfo.ErrorClass, out errors)) { errors = new List<ErrorInfo>(); errorClass2ErrorInfo[errorInfo.ErrorClass] = errors; } errors.Add(errorInfo); }