WCF service reference to service using Framework complex types (Version) RRS feed

  • Question

  • I recently exposed a System.Version through the OData interface, which appears to work happily as Version is a 'simple' type that easily can be represented as an OData Complex Type:

    <Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" Namespace="System">
    <ComplexType Name="Version">
    <Property Name="Major" Type="Edm.Int32" Nullable="false"/>
    <Property Name="Minor" Type="Edm.Int32" Nullable="false"/>
    <Property Name="Build" Type="Edm.Int32" Nullable="false"/>
    <Property Name="Revision" Type="Edm.Int32" Nullable="false"/>
    <Property Name="MajorRevision" Type="Edm.Int16" Nullable="false"/>
    <Property Name="MinorRevision" Type="Edm.Int16" Nullable="false"/>


    Now, arguably the MajorRevision/MinorRevision properties should be ignored, but regardless.  Add/Update Service reference fails for these types as they are existing framework types... should it?


    Craig Dean (MCPD)
    Chief Executive

    Please consider marking this as the answer if you have been genuinely helped!

    Friday, January 25, 2013 3:47 PM

All replies

  • Is it failing to generate code or producing code that fails to compile?

    If it's failing to even generate, then this is probably intentional, but I would need to see what the error message looks like.

    Our options here are fairly limited. We certainly don't want to generate another copy of System.Version, as that would lead to lots of compilation issues. We could try to detect whether an EDM type perfectly matches a System type and just reuse the system type, but it's not a scenario we've seen much demand for (though it's perfectly valid). We could also invest more in opening up the Add Service Reference experience to allow more customized generators, and in particular allow the use of custom T4 templates. The last option is the most flexible and has been often discussed by the team, but has not yet been committed to for any particular release.

    For now, once we have a better sense of where it's failing we can see if there is a workaround or not.

    Matt Meehan (WCF Data Services / OData)

    Friday, January 25, 2013 4:43 PM
  • Yes, the add service wizard fails because the generator fails due to the schema namespace being 'System', it is easily reproducable by using the above schema.

    Obviously, generating an existing framework type is not an option as you say, I found lots of usage cases that don't appear to be anticipated in the current implementations (my service has way too many workarounds in it).   I would say that if an EDM schema type matches an existing framework type then it would be reasonable to map to that type, however the workaround (create an explicit Complex Type and map to and from it) isn't the end of the world.

    Having access to the T4's is a vastly superior idea in the end, as it allows us to change it completely (e.g. implement async methods, etc.) so I'd go with that - particularly as VS2012 is so much more T4 friendly.


    Craig Dean (MCPD)
    Chief Executive

    Please consider marking this as the answer if you have been genuinely helped!

    • Proposed as answer by SilentJealousy Tuesday, January 29, 2013 8:33 AM
    Friday, January 25, 2013 8:56 PM