From: <mcu...@us...> - 2014-11-21 17:47:19
|
Revision: 1551 http://sourceforge.net/p/orm/code/1551 Author: mcurland Date: 2014-11-21 17:47:16 +0000 (Fri, 21 Nov 2014) Log Message: ----------- Bug fixes: * Fix sample population editor VS crash with recursive identifiers. * Allow test framework to run on 64-bit machines. Modified Paths: -------------- trunk/ORM2CommandLineTest/ReportViewer.csproj trunk/ORM2CommandLineTest/TestDriverApp.csproj trunk/ORM2CommandLineTest/install.bat trunk/ORMModel/ObjectModel/SamplePopulation.cs trunk/ORMModel/Shell/SamplePopulationEditor.cs Modified: trunk/ORM2CommandLineTest/ReportViewer.csproj =================================================================== --- trunk/ORM2CommandLineTest/ReportViewer.csproj 2014-11-21 16:29:21 UTC (rev 1550) +++ trunk/ORM2CommandLineTest/ReportViewer.csproj 2014-11-21 17:47:16 UTC (rev 1551) @@ -21,6 +21,7 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <NoWarn>1607</NoWarn> + <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -30,6 +31,7 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <NoWarn>1607</NoWarn> + <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <ItemGroup> <Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> @@ -135,4 +137,4 @@ <PropertyGroup> <PostBuildEvent>"$(ProjectDir)install.bat" "$(ProjectDir)" "$(OutDir)" "$(DevEnvDir)\..\..\" "$(TargetVisualStudioShortProductName)" "$(TargetVisualStudioLongProductName)"</PostBuildEvent> </PropertyGroup> -</Project> +</Project> \ No newline at end of file Modified: trunk/ORM2CommandLineTest/TestDriverApp.csproj =================================================================== --- trunk/ORM2CommandLineTest/TestDriverApp.csproj 2014-11-21 16:29:21 UTC (rev 1550) +++ trunk/ORM2CommandLineTest/TestDriverApp.csproj 2014-11-21 17:47:16 UTC (rev 1551) @@ -36,6 +36,7 @@ <OutputPath>bin\Debug\</OutputPath> <DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants> <NoWarn>1607</NoWarn> + <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugSymbols>false</DebugSymbols> @@ -43,6 +44,7 @@ <OutputPath>.\bin\Release\</OutputPath> <DefineConstants>$(DefineConstants);TRACE</DefineConstants> <NoWarn>1607</NoWarn> + <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <ItemGroup> <Reference Include="Microsoft.VisualStudio.Modeling.Sdk, Version=$(TargetDslToolsAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> @@ -94,4 +96,4 @@ <PropertyGroup> <PostBuildEvent>"$(ProjectDir)install.bat" "$(ProjectDir)" "$(OutDir)" "$(DevEnvDir)\..\..\" "$(TargetVisualStudioShortProductName)" "$(TargetVisualStudioLongProductName)"</PostBuildEvent> </PropertyGroup> -</Project> +</Project> \ No newline at end of file Modified: trunk/ORM2CommandLineTest/install.bat =================================================================== --- trunk/ORM2CommandLineTest/install.bat 2014-11-21 16:29:21 UTC (rev 1550) +++ trunk/ORM2CommandLineTest/install.bat 2014-11-21 17:47:16 UTC (rev 1551) @@ -9,9 +9,9 @@ ) if '%1'=='' ( -set rootPath=%~dp0 +CALL:SETVAR "rootPath" "%~dp0" ) else ( -set rootPath=%~dp1 +CALL:SETVAR "rootPath" "%~dp1" ) if '%2'=='' ( set outDir=bin\Debug\ @@ -19,9 +19,9 @@ set outDir=%~2 ) if '%3'=='' ( -set envPath=%ResolvedProgramFiles%\Microsoft Visual Studio 8\ +CALL:SETVAR "envPath" "%ResolvedProgramFiles%\Microsoft Visual Studio 8\" ) else ( -set envPath=%~dp3 +CALL:SETVAR "envPath" "%~dp3" ) if '%4'=='' ( set VSProduct=VS2005 @@ -89,3 +89,7 @@ SET WOWRegistryAdjust=\Wow6432Node ) GOTO:EOF + +:SETVAR +SET %~1=%~2 +GOTO:EOF Modified: trunk/ORMModel/ObjectModel/SamplePopulation.cs =================================================================== --- trunk/ORMModel/ObjectModel/SamplePopulation.cs 2014-11-21 16:29:21 UTC (rev 1550) +++ trunk/ORMModel/ObjectModel/SamplePopulation.cs 2014-11-21 17:47:16 UTC (rev 1551) @@ -3600,7 +3600,7 @@ valueNonTextFormat = null; } string listSeparator = null; - string retVal = (parentObjectType == null) ? "" : RecurseObjectTypeInstanceValue(objectInstance, parentObjectType, ignoreObjectification, false, null, null, ref listSeparator, ref outputText, formatProvider, valueTextFormat, valueNonTextFormat, false); + string retVal = (parentObjectType == null) ? "" : RecurseObjectTypeInstanceValue(objectInstance, parentObjectType, ignoreObjectification, false, null, null, ref listSeparator, ref outputText, formatProvider, valueTextFormat, valueNonTextFormat, false, null); retVal = (outputText != null) ? outputText.ToString() : retVal; return (retVal == null) ? "" : retVal.Trim(); } @@ -3627,12 +3627,12 @@ valueNonTextFormat = null; } string listSeparator = null; - string retVal = (parentFactType == null) ? "" : RecurseObjectTypeInstanceValue(null, null, false, false, factInstance, parentFactType, ref listSeparator, ref outputText, formatProvider, valueTextFormat, valueNonTextFormat, false); + string retVal = (parentFactType == null) ? "" : RecurseObjectTypeInstanceValue(null, null, false, false, factInstance, parentFactType, ref listSeparator, ref outputText, formatProvider, valueTextFormat, valueNonTextFormat, false, null); retVal = (outputText != null) ? outputText.ToString() : retVal; return (retVal == null) ? "" : retVal.Trim(); } - private static string RecurseObjectTypeInstanceValue(ObjectTypeInstance objectInstance, ObjectType parentObjectType, bool ignoreObjectification, bool nestedLeadValue, FactTypeInstance factInstance, FactType parentFactType, ref string listSeparator, ref StringBuilder outputText, IFormatProvider formatProvider, string valueTextFormat, string valueNonTextFormat, bool outerGrouping) + private static string RecurseObjectTypeInstanceValue(ObjectTypeInstance objectInstance, ObjectType parentObjectType, bool ignoreObjectification, bool nestedLeadValue, FactTypeInstance factInstance, FactType parentFactType, ref string listSeparator, ref StringBuilder outputText, IFormatProvider formatProvider, string valueTextFormat, string valueNonTextFormat, bool outerGrouping, Predicate<ObjectType> stackCheck) { string blankValueText = nestedLeadValue ? " " : ""; DataType dataType; @@ -3668,12 +3668,22 @@ } return valueText; } + else if (parentObjectType != null && objectInstance == null && stackCheck != null && stackCheck(parentObjectType)) + { + if (outputText != null) + { + outputText.Append(blankValueText); + return null; + } + return blankValueText; + } else { IList<Role> roles = null; int roleCount = 0; FactType objectifiedFactType = null; EntityTypeInstance entityInstance = null; + Predicate<ObjectType> recurseStackCheck = null; if (parentFactType != null) { // Just do the FactType tuple, without any identifier parts @@ -3712,7 +3722,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - outerGrouping); + outerGrouping, + stackCheck); } else if (preferredFor != null && preferredFor != parentObjectType) { @@ -3739,7 +3750,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - false); + false, + recurseStackCheck ?? (recurseStackCheck = CreateRecursiveIdentifierStackCheck(preferredFor, stackCheck))); outputText.Append(listSeparator ?? (listSeparator = GetListSeparator(formatProvider))); RecurseObjectTypeInstanceValue( null, @@ -3753,7 +3765,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - true); + true, + stackCheck); if (!outerGrouping) { outputText.Append(")"); @@ -3776,7 +3789,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - outerGrouping); + outerGrouping, + recurseStackCheck ?? (recurseStackCheck = CreateRecursiveIdentifierStackCheck(preferredFor, stackCheck))); } entityInstance = objectInstance as EntityTypeInstance; if (identifier != null) @@ -3826,9 +3840,10 @@ { roleInstance = factInstance.FindRoleInstance(role); } + ObjectType rolePlayer = role.RolePlayer; string retVal = RecurseObjectTypeInstanceValue( (roleInstance != null) ? roleInstance.ObjectTypeInstance : null, - role.RolePlayer, + rolePlayer, false, nestedLeadValue, null, @@ -3838,7 +3853,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - false); + false, + recurseStackCheck ?? (recurseStackCheck = CreateRecursiveIdentifierStackCheck(rolePlayer, stackCheck))); if (objectifiedFactType == null) { return retVal; @@ -3906,9 +3922,10 @@ } } } + ObjectType rolePlayer = role.RolePlayer; RecurseObjectTypeInstanceValue( (matchInstance != null) ? matchInstance.ObjectTypeInstance : null, - role.RolePlayer, + rolePlayer, false, i == 0 && !outerGrouping, null, @@ -3918,7 +3935,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - false); + false, + recurseStackCheck ?? (recurseStackCheck = CreateRecursiveIdentifierStackCheck(rolePlayer, stackCheck))); } if (!outerGrouping) { @@ -3941,7 +3959,8 @@ formatProvider, valueTextFormat, valueNonTextFormat, - true); + true, + stackCheck); if (!outerGrouping) { outputText.Append(")"); @@ -3950,6 +3969,22 @@ return null; } } + /// <summary> + /// Helper to create a delegate to determine if an identifier is recursively defined. If we have + /// a recursive identifier then we do not continue past an empty instance. + /// </summary> + /// <param name="rolePlayer">The current role player.</param> + /// <param name="contextStackCheck">A context delegate from higher up in the object tree.</param> + /// <returns>New stack check.</returns> + private static Predicate<ObjectType> CreateRecursiveIdentifierStackCheck(ObjectType rolePlayer, Predicate<ObjectType> contextStackCheck) + { + return rolePlayer == null ? + contextStackCheck : + delegate(ObjectType recursiveRolePlayer) + { + return rolePlayer == recursiveRolePlayer || (contextStackCheck != null && contextStackCheck(recursiveRolePlayer)); + }; + } private static string GetListSeparator(IFormatProvider formatProvider) { CultureInfo cultureInfo = formatProvider as CultureInfo ?? CultureInfo.CurrentCulture; Modified: trunk/ORMModel/Shell/SamplePopulationEditor.cs =================================================================== --- trunk/ORMModel/Shell/SamplePopulationEditor.cs 2014-11-21 16:29:21 UTC (rev 1550) +++ trunk/ORMModel/Shell/SamplePopulationEditor.cs 2014-11-21 17:47:16 UTC (rev 1551) @@ -3133,7 +3133,7 @@ public static string DeriveColumnName(Role role, bool ignoreObjectification) { StringBuilder outputText = null; - string retVal = (role == null || role.RolePlayer == null) ? ResourceStrings.ModelSamplePopulationEditorNullSelection : RecurseColumnIdentifier(role, null, ignoreObjectification, null, ref outputText); + string retVal = (role == null || role.RolePlayer == null) ? ResourceStrings.ModelSamplePopulationEditorNullSelection : RecurseColumnIdentifier(role, null, ignoreObjectification, null, null, ref outputText); return (outputText != null) ? outputText.ToString() : retVal; } public static string DeriveColumnName(ObjectType objectType) @@ -3143,7 +3143,7 @@ public static string DeriveColumnName(ObjectType objectType, bool ignoreObjectification) { StringBuilder outputText = null; - string retVal = (objectType == null) ? ResourceStrings.ModelSamplePopulationEditorNullSelection : RecurseColumnIdentifier(null, objectType, ignoreObjectification, null, ref outputText); + string retVal = (objectType == null) ? ResourceStrings.ModelSamplePopulationEditorNullSelection : RecurseColumnIdentifier(null, objectType, ignoreObjectification, null, null, ref outputText); return (outputText != null) ? outputText.ToString() : retVal; } protected static string GetRolePlayerTypeName(Role role, bool useRoleName) @@ -3158,7 +3158,7 @@ return retVal; } // UNDONE: This whole method needs to be localized - private static string RecurseColumnIdentifier(Role role, ObjectType rolePlayer, bool ignoreObjectification, string listSeparator, ref StringBuilder outputText) + private static string RecurseColumnIdentifier(Role role, ObjectType rolePlayer, bool ignoreObjectification, string listSeparator, Predicate<ObjectType> stackCheck, ref StringBuilder outputText) { if (rolePlayer == null) { @@ -3169,14 +3169,26 @@ if (outputText != null) { outputText.Append(" "); + return null; } return " "; } + if (stackCheck != null && stackCheck(rolePlayer)) + { + if (outputText != null) + { + outputText.Append(rolePlayer.Name); + outputText.Append(ResourceStrings.ReadingShapeEllipsis); + return null; + } + return rolePlayer.Name + ResourceStrings.ReadingShapeEllipsis; + } string roleName = (role != null) ? role.Name : ""; string derivedName = (roleName.Length != 0) ? roleName : rolePlayer.Name; UniquenessConstraint identifier = null; ObjectType supertypeRolePlayer = null; bool isValueType = rolePlayer.IsValueType; + Predicate<ObjectType> nextStackCheck = isValueType ? stackCheck : null; // The value type won't recurse over its preferred identifier. FactType nestedFactType = (ignoreObjectification || isValueType) ? null : rolePlayer.NestedFactType; bool useIdentifiedReferenceMode = false; if (isValueType) @@ -3221,11 +3233,12 @@ } outputText.Append(derivedName); outputText.Append("("); + bool identifierWritten = false; if (supertypeRolePlayer != null && supertypeRolePlayer != rolePlayer) { - RecurseColumnIdentifier(null, supertypeRolePlayer, false, listSeparator, ref outputText); + RecurseColumnIdentifier(null, supertypeRolePlayer, false, listSeparator, nextStackCheck ?? (nextStackCheck = CreateColumnIdentifierStackCheck(rolePlayer, stackCheck)), ref outputText); identifierWritten = true; } else @@ -3262,7 +3275,7 @@ { outputText.Append(listSeparator); } - RecurseColumnIdentifier(identifierRole, null, false, listSeparator, ref outputText); + RecurseColumnIdentifier(identifierRole, null, false, listSeparator, nextStackCheck ?? (nextStackCheck = CreateColumnIdentifierStackCheck(rolePlayer, stackCheck)), ref outputText); } } identifierWritten = true; @@ -3287,13 +3300,26 @@ { outputText.Append(listSeparator); } - RecurseColumnIdentifier(factRole, null, false, listSeparator, ref outputText); + RecurseColumnIdentifier(factRole, null, false, listSeparator, nextStackCheck ?? (nextStackCheck = CreateColumnIdentifierStackCheck(rolePlayer, stackCheck)), ref outputText); } } outputText.Append(")"); return null; } /// <summary> + /// Helper to create a delegate to determine if a role player is recursively defined. + /// </summary> + /// <param name="rolePlayer">The current role player.</param> + /// <param name="contextStackCheck">A context delegate from higher up in the object tree.</param> + /// <returns>New stack check.</returns> + private static Predicate<ObjectType> CreateColumnIdentifierStackCheck(ObjectType rolePlayer, Predicate<ObjectType> contextStackCheck) + { + return delegate(ObjectType recursiveRolePlayer) + { + return rolePlayer == recursiveRolePlayer || (contextStackCheck != null && contextStackCheck(recursiveRolePlayer)); + }; + } + /// <summary> /// Determine if the specified instance is empty. A <see cref="ValueTypeInstance"/> /// is never empty, an <see cref="EntityTypeInstance"/> is empty if it has not /// attached instances, and a <see cref="EntityTypeSubtypeInstance"/> is empty if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |