Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
More T4 validating and debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
msawczyn committed Nov 14, 2020
1 parent d5ef358 commit aa05f1f
Show file tree
Hide file tree
Showing 45 changed files with 5,060 additions and 3,217 deletions.
Expand Up @@ -14,7 +14,7 @@ private static bool CanAcceptModelClassAsTarget(ModelClass candidate)
{
// dependent types can't participate in inheritance relationships
// classes can't have > 1 superclass
return !candidate.IsDependentType && candidate.Superclass == null;
return !candidate.IsDependentType && candidate.Superclass == null && !candidate.IsPropertyBag;
}

private static bool CanAcceptModelClassAndModelClassAsSourceAndTarget(ModelClass sourceModelClass, ModelClass targetModelClass)
Expand Down
3 changes: 3 additions & 0 deletions src/Dsl/CustomCode/Partials/ModelClass.cs
Expand Up @@ -247,6 +247,9 @@ protected string GetGlyphTypeValue()
if (!GenerateCode)
return "NoGenGlyph";

if (IsPropertyBag)
return "DictionaryGlyph";

// ReSharper disable once ConvertIfStatementToReturnStatement
if (IsAbstract)
return "AbstractEntityGlyph";
Expand Down
8 changes: 8 additions & 0 deletions src/Dsl/CustomCode/Rules/GeneralizationAddRules.cs
Expand Up @@ -21,6 +21,14 @@ public override void ElementAdded(ElementAddedEventArgs e)
if (current.IsSerializing || ModelRoot.BatchUpdating)
return;

if (element.Subclass.IsPropertyBag && !element.Superclass.IsPropertyBag)
{
ErrorDisplay.Show(store, $"{element.Subclass.Name} -> {element.Superclass.Name}: Since {element.Subclass.Name} is a property bag, it can't inherit from {element.Superclass.Name}, which is not a property bag.");
current.Rollback();

return;
}

if (element.IsInCircularInheritance())
{
ErrorDisplay.Show(store, $"{element.Subclass.Name} -> {element.Superclass.Name}: That inheritance link would cause a circular reference.");
Expand Down
8 changes: 8 additions & 0 deletions src/Dsl/CustomCode/Rules/GeneralizationChangeRules.cs
Expand Up @@ -30,6 +30,14 @@ public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
case "Superclass":
case "Subclass":

if (element.Subclass.IsPropertyBag && !element.Superclass.IsPropertyBag)
{
ErrorDisplay.Show(store, $"{element.Subclass.Name} -> {element.Superclass.Name}: Since {element.Subclass.Name} is a property bag, it can't inherit from {element.Superclass.Name}, which is not a property bag.");
current.Rollback();

return;
}

if (!element.IsInCircularInheritance())
{
ErrorDisplay.Show(store, $"{element.Subclass.Name} -> {element.Superclass.Name}: That inheritance link would cause a circular reference.");
Expand Down
14 changes: 14 additions & 0 deletions src/Dsl/CustomCode/Rules/ModelClassChangeRules.cs
Expand Up @@ -242,6 +242,20 @@ public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
break;
}

case "IsPropertyBag":
{
if (element.Superclass != null && !element.Superclass.IsPropertyBag)
element.Superclass.IsPropertyBag = true;

if (element.Subclasses.Any())
{
foreach (ModelClass subclass in element.Subclasses)
subclass.IsPropertyBag = true;
}

PresentationHelper.UpdateClassDisplay(element);
break;
}
case "IsQueryType":
{
if ((bool)e.NewValue)
Expand Down
Expand Up @@ -50,6 +50,9 @@ private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes)
propertyDescriptors.Remove("TableName");
else
propertyDescriptors.Remove("ViewName");

if (modelClass.IsPropertyBag)
propertyDescriptors.Remove("IsDependentType");
}

//Add the descriptors for the tracking properties
Expand Down
1 change: 1 addition & 0 deletions src/Dsl/Dsl.csproj
Expand Up @@ -409,6 +409,7 @@
<Content Include="Resources\cardinality-many-0.png" />
<Content Include="Resources\cardinality-many-1.png" />
<Content Include="Resources\cardinality-many-many.png" />
<Content Include="Resources\Dictionary_16x.png" />
<Content Include="Resources\Enumerator_16x.png" />
<Content Include="Resources\EnumItem_16x.png" />
<Content Include="Resources\EnumValue.png" />
Expand Down
3 changes: 3 additions & 0 deletions src/Dsl/DslDefinition.dsl
Expand Up @@ -1756,6 +1756,9 @@
<ShapeHasDecorators Position="InnerTopLeft" HorizontalOffset="0" VerticalOffset="0">
<IconDecorator Name="NoGenGlyph" DisplayName="No Code Generation" DefaultIcon="Resources\No.png" />
</ShapeHasDecorators>
<ShapeHasDecorators Position="InnerTopLeft" HorizontalOffset="0" VerticalOffset="0">
<IconDecorator Name="DictionaryGlyph" DisplayName="Property Bag" DefaultIcon="Resources\Dictionary_16x.png" />
</ShapeHasDecorators>
<Compartment Name="AttributesCompartment" Title="Properties" />
<Compartment Name="AssociationsCompartment" Title="Association Targets" />
<Compartment Name="SourcesCompartment" Title="Association Sources" />
Expand Down

0 comments on commit aa05f1f

Please sign in to comment.