Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fix for OpenTypeProperties #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ public ODataClientTemplate(CodeGenerationContext context)
internal abstract void WriteParameterNullCheckForStaticCreateMethod(string parameterName);
internal abstract void WritePropertyValueAssignmentForStaticCreateMethod(string instanceName, string propertyName, string parameterName);
internal abstract void WriteMethodEndForStaticCreateMethod(string instanceName);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType);
internal abstract void WriteINotifyPropertyChangedImplementation();
internal abstract void WriteClassEndForStructuredType();
internal abstract void WriteNamespaceEnd();
Expand Down Expand Up @@ -2511,7 +2511,8 @@ internal void WritePropertiesForStructuredType(IEnumerable<IEdmProperty> propert
PropertyName = propertyName,
FixedPropertyName = GetFixedName(propertyName),
PrivatePropertyName = "_" + propertyName,
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context)
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context),
IsOpenTypeProperty = false
};
}).ToList();

Expand All @@ -2524,7 +2525,8 @@ internal void WritePropertiesForStructuredType(IEnumerable<IEdmProperty> propert
PropertyName = this.context.DynamicPropertiesCollectionName,
FixedPropertyName = GetFixedName(this.context.DynamicPropertiesCollectionName),
PrivatePropertyName = "_" + Utils.CamelCase(this.context.DynamicPropertiesCollectionName),
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName)
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName),
IsOpenTypeProperty = true
});
}

Expand All @@ -2543,7 +2545,8 @@ internal void WritePropertiesForStructuredType(IEnumerable<IEdmProperty> propert
propertyInfo.FixedPropertyName,
privatePropertyName,
propertyInfo.PropertyInitializationValue,
useDataServiceCollection);
useDataServiceCollection,
propertyInfo.IsOpenTypeProperty);
}
}

Expand Down Expand Up @@ -4517,7 +4520,7 @@ internal override void WriteMethodEndForStaticCreateMethod(string instanceName)

}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{

this.Write(" /// <summary>\r\n /// There are no comments for Property ");
Expand All @@ -4531,8 +4534,13 @@ internal override void WritePropertyForStructuredType(string propertyType, strin

this.Write("\")]\r\n");

if (isOpenType)
{
this.Write(" [global::Microsoft.OData.Client.ContainerProperty]\r\n");
}

if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))

if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{

this.Write(" [global::Microsoft.OData.Client.OriginalNameAttribute(\"");
Expand Down Expand Up @@ -6606,7 +6614,7 @@ internal override void WriteMethodEndForStaticCreateMethod(string instanceName)

}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{

this.Write(" \'\'\'<summary>\r\n \'\'\'There are no comments for Property ");
Expand All @@ -6620,6 +6628,10 @@ internal override void WritePropertyForStructuredType(string propertyType, strin

this.Write("\")> _\r\n");

if(isOpenType)
{
this.Write(" <Global.Microsoft.OData.Client.ContainerProperty>\r\n");
}

if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = propertyName,
FixedPropertyName = GetFixedName(propertyName),
PrivatePropertyName = "_" + propertyName,
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context)
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context),
IsOpenTypeProperty = false
};
}).ToList();

Expand All @@ -2453,7 +2454,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = this.context.DynamicPropertiesCollectionName,
FixedPropertyName = GetFixedName(this.context.DynamicPropertiesCollectionName),
PrivatePropertyName = "_" + Utils.CamelCase(this.context.DynamicPropertiesCollectionName),
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName)
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName),
IsOpenTypeProperty = true
});
}

Expand All @@ -2472,7 +2474,8 @@ public abstract class ODataClientTemplate : TemplateBase
propertyInfo.FixedPropertyName,
privatePropertyName,
propertyInfo.PropertyInitializationValue,
useDataServiceCollection);
useDataServiceCollection,
propertyInfo.IsOpenTypeProperty);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ public abstract class ODataClientTemplate : TemplateBase
internal abstract void WriteParameterNullCheckForStaticCreateMethod(string parameterName);
internal abstract void WritePropertyValueAssignmentForStaticCreateMethod(string instanceName, string propertyName, string parameterName);
internal abstract void WriteMethodEndForStaticCreateMethod(string instanceName);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType);
internal abstract void WriteINotifyPropertyChangedImplementation();
internal abstract void WriteClassEndForStructuredType();
internal abstract void WriteNamespaceEnd();
Expand Down Expand Up @@ -2440,7 +2440,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = propertyName,
FixedPropertyName = GetFixedName(propertyName),
PrivatePropertyName = "_" + propertyName,
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context)
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context),
IsOpenTypeProperty = false
};
}).ToList();

Expand All @@ -2453,7 +2454,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = this.context.DynamicPropertiesCollectionName,
FixedPropertyName = GetFixedName(this.context.DynamicPropertiesCollectionName),
PrivatePropertyName = "_" + Utils.CamelCase(this.context.DynamicPropertiesCollectionName),
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName)
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName),
IsOpenTypeProperty = true
});
}

Expand All @@ -2472,7 +2474,8 @@ public abstract class ODataClientTemplate : TemplateBase
propertyInfo.FixedPropertyName,
privatePropertyName,
propertyInfo.PropertyInitializationValue,
useDataServiceCollection);
useDataServiceCollection,
propertyInfo.IsOpenTypeProperty);
}
}

Expand Down Expand Up @@ -4065,13 +4068,22 @@ namespace <#= fullNamespace #>
<#+
}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{
#>
/// <summary>
/// There are no comments for Property <#= propertyName #> in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "<#=T4Version#>")]

<#+
if (isOpenType)
{
#>
[global::Microsoft.OData.Client.ContainerProperty]
<#+
}
#>
<#+
if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{
Expand Down Expand Up @@ -5110,13 +5122,21 @@ Namespace <#= fullNamespace #>
<#+
}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{
#>
'''<summary>
'''There are no comments for Property <#= propertyName #> in the schema.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "<#=T4Version#>")> _
<#+
if (isOpenType)
{
#>
<Global.Microsoft.OData.Client.ContainerProperty> _
<#+
}
#>
<#+
if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ public abstract class ODataClientTemplate : TemplateBase
internal abstract void WriteParameterNullCheckForStaticCreateMethod(string parameterName);
internal abstract void WritePropertyValueAssignmentForStaticCreateMethod(string instanceName, string propertyName, string parameterName);
internal abstract void WriteMethodEndForStaticCreateMethod(string instanceName);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged);
internal abstract void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType);
internal abstract void WriteINotifyPropertyChangedImplementation();
internal abstract void WriteClassEndForStructuredType();
internal abstract void WriteNamespaceEnd();
Expand Down Expand Up @@ -2440,7 +2440,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = propertyName,
FixedPropertyName = GetFixedName(propertyName),
PrivatePropertyName = "_" + propertyName,
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context)
PropertyInitializationValue = Utils.GetPropertyInitializationValue(property, useDataServiceCollection, this, this.context),
IsOpenTypeProperty = false
};
}).ToList();

Expand All @@ -2453,7 +2454,8 @@ public abstract class ODataClientTemplate : TemplateBase
PropertyName = this.context.DynamicPropertiesCollectionName,
FixedPropertyName = GetFixedName(this.context.DynamicPropertiesCollectionName),
PrivatePropertyName = "_" + Utils.CamelCase(this.context.DynamicPropertiesCollectionName),
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName)
PropertyInitializationValue = string.Format(this.DictionaryConstructor, this.StringTypeName, this.ObjectTypeName),
IsOpenTypeProperty = true
});
}

Expand All @@ -2472,7 +2474,8 @@ public abstract class ODataClientTemplate : TemplateBase
propertyInfo.FixedPropertyName,
privatePropertyName,
propertyInfo.PropertyInitializationValue,
useDataServiceCollection);
useDataServiceCollection,
propertyInfo.IsOpenTypeProperty);
}
}

Expand Down Expand Up @@ -4065,13 +4068,21 @@ namespace <#= fullNamespace #>
<#+
}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{
#>
/// <summary>
/// There are no comments for Property <#= propertyName #> in the schema.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "<#=T4Version#>")]
<#+
if (isOpenType)
{
#>
[global::Microsoft.OData.Client.ContainerProperty]
<#+
}
#>
<#+
if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{
Expand Down Expand Up @@ -5110,13 +5121,21 @@ Namespace <#= fullNamespace #>
<#+
}

internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged)
internal override void WritePropertyForStructuredType(string propertyType, string originalPropertyName, string propertyName, string fixedPropertyName, string privatePropertyName, string propertyInitializationValue, bool writeOnPropertyChanged, bool isOpenType)
{
#>
'''<summary>
'''There are no comments for Property <#= propertyName #> in the schema.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "<#=T4Version#>")> _
<#+
if (isOpenType)
{
#>
<Global.Microsoft.OData.Client.ContainerProperty> _
<#+
}
#>
<#+
if (this.context.EnableNamingAlias || IdentifierMappings.ContainsKey(originalPropertyName))
{
Expand Down