Skip to content

Commit

Permalink
Removed support for null property rendering which was made obsolete b…
Browse files Browse the repository at this point in the history
…y dynamic profiles. (#777)
  • Loading branch information
gmcelhanon authored Aug 8, 2023
1 parent 6a65bc0 commit 87c5906
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,6 @@ public static object CreatePropertyDto(PropertyData propertyData)
{
switch (propertyData[ResourceRenderer.RenderType])
{
case ResourceRenderer.RenderNull:

return new
{
Null = new { },
Property = propertyData.Render()
};
case ResourceRenderer.RenderNullLookup:

return new
{
NullLookup = new { },
Property = propertyData.Render()
};
case ResourceRenderer.RenderStandard:

return new
Expand Down Expand Up @@ -343,17 +329,5 @@ public static PropertyData CreateUsiPrimaryKey(ResourceProperty property)

return data;
}

public static PropertyData CreateNullProperty(ResourceProperty property)
{
var propertyData = CreateStandardProperty(property);

propertyData[ResourceRenderer.RenderType] =
property.IsDescriptorUsage
? ResourceRenderer.RenderNullLookup
: ResourceRenderer.RenderNull;

return propertyData;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,11 @@ public object AssembleInheritedProperties(ResourceClassBase resource)
throw new ArgumentNullException(nameof(resource));
}

IList<ResourcePropertyData> includedProperties = null;
IList<ResourceProperty> includedProperties = null;

includedProperties = resource.InheritedProperties()
.OrderBy(x => x.PropertyName)
.Where(x => !x.IsIdentifying && !x.PropertyName.Equals("Id"))
.Select(
x => new ResourcePropertyData
{
Property = x,
IsStandardProperty = false
})
.ToList();

var propertiesToRender = new List<PropertyData>();
Expand All @@ -246,9 +240,7 @@ public object AssembleInheritedProperties(ResourceClassBase resource)
includedProperties.Select(
x =>
{
var propertyData = x.IsStandardProperty
? PropertyData.CreateNullProperty(x.Property)
: PropertyData.CreateStandardProperty(x.Property);
var propertyData = PropertyData.CreateStandardProperty(x);

propertyData[ResourceRenderer.MiscellaneousComment] = "// NOT in a reference, NOT a lookup column ";
return propertyData;
Expand All @@ -258,9 +250,7 @@ public object AssembleInheritedProperties(ResourceClassBase resource)
{
propertiesToRender.AddRange(
includedProperties.Select(
x => x.IsStandardProperty
? PropertyData.CreateNullProperty(x.Property)
: PropertyData.CreateStandardProperty(x.Property)));
PropertyData.CreateStandardProperty));
}

return propertiesToRender.Any()
Expand Down Expand Up @@ -408,14 +398,6 @@ orderby p.PropertyName

foreach (var propertyPair in propertyPairs)
{
// If the property was filtered out, then generate an explicit interface "Null" implementation only.
if (propertyPair.CurrentProperty == null)
{
yield return PropertyData.CreateNullProperty(propertyPair.UnderlyingProperty);

continue;
}

var property = propertyPair.CurrentProperty;

if (property.IsSynchronizable())
Expand Down Expand Up @@ -454,12 +436,5 @@ orderby p.PropertyName
}
}
}

private class ResourcePropertyData
{
public ResourceProperty Property { get; set; }

public bool IsStandardProperty { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public static class ResourceRenderer
public const string RenderReferenced = "referenced";
public const string RenderUnified = "unified";
public const string RenderUsi = "usi";
public const string RenderNull = "null";
public const string RenderNullLookup = "nullLookup";
public const object DoNotRenderProperty = null;
public const bool DoRenderProperty = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,26 +482,6 @@ namespace {{ResourceClassesNamespace}}
{{/PropertyDefaultHasDomainMeaning}}
{{/Property}}
{{/Standard}}
{{#Null}}
{{#Property}}
// NOT a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{ParentNamespacePrefix}}I{{ParentName}}.{{PropertyName}}
{
get { return default({{PropertyType}}); }
set { }
}
{{/Property}}
{{/Null}}
{{#NullLookup}}
{{#Property}}
// IS a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{ParentNamespacePrefix}}I{{ParentName}}.{{PropertyName}}
{
get { return null; }
set { }
}
{{/Property}}
{{/NullLookup}}
{{#Referenced}}
{{#Property}}

Expand Down Expand Up @@ -828,28 +808,6 @@ namespace {{ResourceClassesNamespace}}
public {{PropertyType}} {{PropertyName}} { get; set; }
{{/Property}}
{{/Standard}}
{{#Null}}

{{#Property}}
// NOT a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{PropertyNamespacePrefix}}I{{ParentName}}.{{PropertyName}}
{
get { return default({{PropertyType}}); }
set { }
}
{{/Property}}
{{/Null}}
{{#NullLookup}}

{{#Property}}
// IS a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{PropertyNamespacePrefix}}I{{ParentName}}.{{PropertyName}}
{
get { return null; }
set { }
}
{{/Property}}
{{/NullLookup}}
{{/Properties}}
{{/InheritedProperties}}
// -------------------------------------------------------------
Expand Down Expand Up @@ -1008,28 +966,6 @@ namespace {{ResourceClassesNamespace}}
{{/PropertyDefaultHasDomainMeaning}}
{{/Property}}
{{/Standard}}
{{#Null}}

{{#Property}}
// NOT a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{NullPropertyPrefix}}{{CSharpSafePropertyName}}
{
get { return default({{PropertyType}}); }
set { }
}
{{/Property}}
{{/Null}}
{{#NullLookup}}

{{#Property}}
// IS a lookup column, Not supported by this model, so there's "null object pattern" style implementation
{{PropertyType}} {{NullPropertyPrefix}}{{PropertyName}}
{
get { return null; }
set { }
}
{{/Property}}
{{/NullLookup}}
{{/Properties}}
{{/NonIdentifiers}}
// -------------------------------------------------------------
Expand Down

0 comments on commit 87c5906

Please sign in to comment.