From: <mcu...@us...> - 2009-01-08 22:49:00
|
Revision: 1350 http://orm.svn.sourceforge.net/orm/?rev=1350&view=rev Author: mcurland Date: 2009-01-08 22:48:55 +0000 (Thu, 08 Jan 2009) Log Message: ----------- Duplicate constraint names are blocking file load with a null reference exception. This fixes a bug introduced in [1343]. Most duplicate constraint names can be fixed by double-clicking on them and clearing the name, which will regenerate. However, duplicate names for some implied constraints cannot be selected and require an XML edit to fix (find the name on an element, delete the contents of the Name attribute (leave Name=""), save, and reload). Duplicate generated names will be automatically fixed in a future changeset. refs #383 Modified Paths: -------------- trunk/ORMModel/ObjectModel/ORMModel.cs trunk/ORMModel/ObjectModel/ORMModel.resx trunk/ORMModel/Resources/ResourceStringsGenerator.cs trunk/ORMModel/Resources/ResourceStringsGenerator.xml Modified: trunk/ORMModel/ObjectModel/ORMModel.cs =================================================================== --- trunk/ORMModel/ObjectModel/ORMModel.cs 2009-01-01 04:29:35 UTC (rev 1349) +++ trunk/ORMModel/ObjectModel/ORMModel.cs 2009-01-08 22:48:55 UTC (rev 1350) @@ -2055,6 +2055,7 @@ [ModelErrorDisplayFilter(typeof(NameErrorCategory))] public partial class ConstraintDuplicateNameError : DuplicateNameError, IHasIndirectModelErrorOwner { + #region Base overrides /// <summary> /// Get the duplicate elements represented by this DuplicateNameError /// </summary> @@ -2063,7 +2064,7 @@ { get { - return ConstraintCollection as IList<ModelElement>; + return ConstraintCollection; } } /// <summary> @@ -2085,6 +2086,7 @@ return ResourceStrings.ModelErrorModelHasDuplicateConstraintNames; } } + #endregion // Base overrides #region ConstraintCollection Implementation [NonSerialized] private CompositeCollection myCompositeList; @@ -2093,14 +2095,14 @@ /// single column external, multi column external, internal constraints, and value constraints /// </summary> /// <value></value> - public IList<ORMNamedElement> ConstraintCollection + public IList<ModelElement> ConstraintCollection { get { return myCompositeList ?? (myCompositeList = new CompositeCollection(this)); } } - private sealed class CompositeCollection : IList<ORMNamedElement> + private sealed class CompositeCollection : IList<ModelElement> { #region Member Variables private readonly LinkedElementCollection<SetComparisonConstraint> myList1; @@ -2115,8 +2117,8 @@ myList3 = error.ValueConstraintCollection; } #endregion // Constructors - #region IList<ORMNamedElement> Implementation - int IList<ORMNamedElement>.IndexOf(ORMNamedElement value) + #region IList<ModelElement> Implementation + int IList<ModelElement>.IndexOf(ModelElement value) { SetComparisonConstraint setComparisonConstraint; SetConstraint setConstraint; @@ -2135,7 +2137,7 @@ } return -1; } - ORMNamedElement IList<ORMNamedElement>.this[int index] + ModelElement IList<ModelElement>.this[int index] { get { @@ -2144,7 +2146,7 @@ { index -= list1Count; int list2Count = myList2.Count; - return (index >= list2Count) ? (ORMNamedElement)myList3[index - list2Count] : myList2[index]; + return (index >= list2Count) ? (ModelElement)myList3[index - list2Count] : myList2[index]; } return myList1[index]; } @@ -2153,17 +2155,17 @@ throw new NotSupportedException(); // Not supported for readonly list } } - void IList<ORMNamedElement>.Insert(int index, ORMNamedElement value) + void IList<ModelElement>.Insert(int index, ModelElement value) { throw new NotSupportedException(); // Not supported for readonly list } - void IList<ORMNamedElement>.RemoveAt(int index) + void IList<ModelElement>.RemoveAt(int index) { throw new NotSupportedException(); // Not supported for readonly list } - #endregion // IList<ORMNamedElement> Implementation - #region ICollection<ORMNamedElement> Implementation - void ICollection<ORMNamedElement>.CopyTo(ORMNamedElement[] array, int index) + #endregion // IList<ModelElement> Implementation + #region ICollection<ModelElement> Implementation + void ICollection<ModelElement>.CopyTo(ModelElement[] array, int index) { int baseIndex = index; int nextCount = myList1.Count; @@ -2184,14 +2186,14 @@ ((ICollection)myList3).CopyTo(array, baseIndex); } } - int ICollection<ORMNamedElement>.Count + int ICollection<ModelElement>.Count { get { return myList1.Count + myList2.Count + myList3.Count; } } - bool ICollection<ORMNamedElement>.Contains(ORMNamedElement value) + bool ICollection<ModelElement>.Contains(ModelElement value) { SetComparisonConstraint setComparisonConstraint; SetConstraint setConstraint; @@ -2210,47 +2212,47 @@ } return false; } - bool ICollection<ORMNamedElement>.IsReadOnly + bool ICollection<ModelElement>.IsReadOnly { get { return true; } } - void ICollection<ORMNamedElement>.Add(ORMNamedElement value) + void ICollection<ModelElement>.Add(ModelElement value) { throw new NotSupportedException(); // Not supported for readonly list } - void ICollection<ORMNamedElement>.Clear() + void ICollection<ModelElement>.Clear() { throw new NotSupportedException(); // Not supported for readonly list } - bool ICollection<ORMNamedElement>.Remove(ORMNamedElement value) + bool ICollection<ModelElement>.Remove(ModelElement value) { throw new NotSupportedException(); // Not supported for readonly list } - #endregion // ICollection<ORMNamedElement> Implementation - #region IEnumerable<ORMNamedElement> Implementation - IEnumerator<ORMNamedElement> IEnumerable<ORMNamedElement>.GetEnumerator() + #endregion // ICollection<ModelElement> Implementation + #region IEnumerable<ModelElement> Implementation + IEnumerator<ModelElement> IEnumerable<ModelElement>.GetEnumerator() { - foreach (ORMNamedElement element in myList1) + foreach (ModelElement element in myList1) { yield return element; } - foreach (ORMNamedElement element in myList2) + foreach (ModelElement element in myList2) { yield return element; } - foreach (ORMNamedElement element in myList3) + foreach (ModelElement element in myList3) { yield return element; } } - #endregion // IEnumerable<ORMNamedElement> Implementation + #endregion // IEnumerable<ModelElement> Implementation #region IEnumerable Implementation IEnumerator IEnumerable.GetEnumerator() { - return ((IEnumerable<ORMNamedElement>)this).GetEnumerator(); + return ((IEnumerable<ModelElement>)this).GetEnumerator(); } #endregion // IEnumerable Implementation } @@ -2288,7 +2290,10 @@ /// </summary> protected override IList<ModelElement> DuplicateElements { - get { return RecognizedPhraseCollection.ToArray(); } + get + { + return RecognizedPhraseCollection.ToArray(); + } } /// <summary> /// Provide an efficient name lookup @@ -2300,12 +2305,13 @@ /// <summary> /// Text to be displayed when an error is thrown. ///</summary> - //TODO: Add this to the ResourceStrings collection protected override string ErrorFormatText { - get { return "Duplicate recognized word exists in the model."; } + get + { + return ResourceStrings.ModelErrorModelHasDuplicateRecognizedPhraseNames; + } } - #region IHasIndirectModelErrorOwner Implementation private static Guid[] myIndirectModelErrorOwnerLinkRoles; /// <summary> Modified: trunk/ORMModel/ObjectModel/ORMModel.resx =================================================================== --- trunk/ORMModel/ObjectModel/ORMModel.resx 2009-01-01 04:29:35 UTC (rev 1349) +++ trunk/ORMModel/ObjectModel/ORMModel.resx 2009-01-08 22:48:55 UTC (rev 1350) @@ -306,6 +306,10 @@ <value>Model '{0}' contains multiple object types named '{1}'. Type names must be unique across all entity and value types in a model.</value> <comment>Model validation error text used when multiple object types with the same name are loaded into a model.Field 0 is the model name, field 1 is the element name.This is an uncommon condition that should only occur with a hand edit to a model file.</comment> </data> + <data name="ModelError.Model.DuplicateRecognizedPhraseNames.Text" xml:space="preserve"> + <value>Model '{0}' contains multiple recognized phrases called '{1}'. Phrase names must be unique across all phrases in a model.</value> + <comment>Model validation error text used when multiple recognized phrases with the same name are loaded into a model.Field 0 is the model name, field 1 is the element name.This is an uncommon condition that should only occur with a hand edit to a model file.</comment> + </data> <data name="ModelError.Model.PopulationMandatoryError.Text" xml:space="preserve"> <value>'{0}' instance '{1}' in model '{2}' must participate in FactType '{3}'{4}.</value> <comment>Model validation error shown when a population violates a mandatory constraint. Field 0 is the name of the role player, field 1 is the derived name of the instance, field 2 is the model name, field 3 is the name of the first facttype name, field 4 is a placeholder for additional fact types.</comment> Modified: trunk/ORMModel/Resources/ResourceStringsGenerator.cs =================================================================== --- trunk/ORMModel/Resources/ResourceStringsGenerator.cs 2009-01-01 04:29:35 UTC (rev 1349) +++ trunk/ORMModel/Resources/ResourceStringsGenerator.cs 2009-01-08 22:48:55 UTC (rev 1350) @@ -925,6 +925,14 @@ return ResourceStrings.GetString(ResourceManagers.Model, "ModelError.Model.DuplicateObjectTypeNames.Text"); } } + /// <summary>Model validation error text used when multiple recognized phrases with the same name are loaded into a model.Field 0 is the model name, field 1 is the element name.This is an uncommon condition that should only occur with a hand edit to a model file.</summary> + public static string ModelErrorModelHasDuplicateRecognizedPhraseNames + { + get + { + return ResourceStrings.GetString(ResourceManagers.Model, "ModelError.Model.DuplicateRecognizedPhraseNames.Text"); + } + } /// <summary>Model validation error shown when a population violates a uniqueness constraint and its role is named. Field 0 is the name of the object type, field 1 is the string representation of the instance, field 2 is the model name, field 3 is the role name.</summary> public static string ModelErrorModelHasPopulationUniquenessErrorWithNamedRole { Modified: trunk/ORMModel/Resources/ResourceStringsGenerator.xml =================================================================== --- trunk/ORMModel/Resources/ResourceStringsGenerator.xml 2009-01-01 04:29:35 UTC (rev 1349) +++ trunk/ORMModel/Resources/ResourceStringsGenerator.xml 2009-01-08 22:48:55 UTC (rev 1350) @@ -163,6 +163,7 @@ <ResourceString name="ModelErrorConstraintExternalConstraintArityMismatch" model="Model" resourceName="ModelError.Constraint.ExternalConstraintArityMismatch.Text"/> <ResourceString name="ModelErrorModelHasDuplicateConstraintNames" model="Model" resourceName="ModelError.Model.DuplicateConstraintNames.Text"/> <ResourceString name="ModelErrorModelHasDuplicateObjectTypeNames" model="Model" resourceName="ModelError.Model.DuplicateObjectTypeNames.Text"/> + <ResourceString name="ModelErrorModelHasDuplicateRecognizedPhraseNames" model="Model" resourceName="ModelError.Model.DuplicateRecognizedPhraseNames.Text"/> <ResourceString name="ModelErrorModelHasPopulationUniquenessErrorWithNamedRole" model="Model" resourceName="ModelError.Model.PopulationUniquenessError.Role.Text"/> <ResourceString name="ModelErrorModelHasPopulationUniquenessErrorWithUnnamedRole" model="Model" resourceName="ModelError.Model.PopulationUniquenessError.FactType.Text"/> <ResourceString name="ModelErrorModelHasPopulationMandatoryError" model="Model" resourceName="ModelError.Model.PopulationMandatoryError.Text"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |