DataMember(Name="") attributes not reflected on the client side


Closed Jun 14 at 12:56 PM by danneesset
Should be fixed in previous releases, this has been resolved for a long time


Tadley wrote Aug 21, 2015 at 3:12 AM

I've stepped through the code and found the issue. In .NET Framework 4.6, Microsoft added a new read-only property (IsNameSetExplicitly) to the DataMemberAttribute class. In the OpenRiaServices.DomainServices.Tools.StandardCustomAttributeBuilder class, the GetAttributeDeclaration method finds this new property and detects that its value differs from its default value. Because the property is read-only, it tries to find a constructor that can set the property. When it fails to find an appropriate constructor, it returns "null, indicating we cannot build this attribute".

The fix is quite simple. There is already a mechanism provided by the code generator to suppress codegen for a property. In the specific case of the DataMemberAttribute, the OpenRiaServices.DomainServices.Tools.DataMemberAttributeBuilder class provides this functionality. Currently, it is suppressing codegen for the Order property. It's just a few lines of code, depending on coding preferences, to tell it to also suppress codegen for the IsNameSetExplicitly property.

I would love to contribute to the project, but I have no idea how to connect to/check-in the code.

ColinBlair wrote Aug 21, 2015 at 1:19 PM

Thanks for finding the problem Tadley. As long as my external constraints (aka my job) allow me I plan to have a new release of Open RIA Services and VS 2015 tooling out at the end of this month.

ColinBlair wrote Aug 26, 2015 at 9:25 PM

The NuGet packages have been pushed. The tooling is delayed.