locked
Using winmd files from other languages

    Question

  • I'm trying to build my custom VS language (.net one) against winrt; it mostly works except that I cannot find how to translate winmd to the right .NET classes. Is the transformation hardcoded or is it defined somewhere? I can't use the unmanaged metadata interfaces to read this, we use a custom library (Cecil) to read references. Are there any docs on how these types are translated?
    Friday, March 2, 2012 1:41 PM

Answers

  • Hello Carlo,

    CLR team is working on documentation of the projections (aka mapping between WinRT and .NET types).

    You can get the full list of mapped types yourself by creating a C# program that will have typeof(WinRTType1); typeof(WinRTType2); etc. You can use ildasm (with /met argument) on .winmd files to get list of all public WinRT types.

    Here is a list of most of the projected types from our source code. DISCLAIMER: The list is not guaranteed, verified and may not be final for .NET 4.5 RTM!!!

    CLASS "Windows.Foundation.Metadata.AttributeUsageAttribute", "System.AttributeUsageAttribute"
    ENUM "Windows.Foundation.Metadata.AttributeTargets", "System.AttributeTargets"
    STRUCT "Windows.UI.Color", "Windows.UI.Color"
    STRUCT "Windows.Foundation.DateTime", "System.DateTimeOffset"
    DELEGATE "Windows.Foundation.EventHandler`1", "System.EventHandler`1"
    STRUCT "Windows.Foundation.EventRegistrationToken", "System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken
    STRUCT "Windows.Foundation.HResult", "System.Exception"
    INTERFACE "Windows.Foundation.IReference`1", "System.Nullable`1"
    STRUCT "Windows.Foundation.Point", "Windows.Foundation.Point"
    STRUCT "Windows.Foundation.Rect", "Windows.Foundation.Rect"
    STRUCT "Windows.Foundation.Size", "Windows.Foundation.Size"
    STRUCT "Windows.Foundation.TimeSpan", "System.TimeSpan"
    RUNTIMECLASS "Windows.Foundation.Uri", "System.Uri"
    INTERFACE "Windows.Foundation.IClosable", "System.IDisposable"
    INTERFACE "Windows.Foundation.Collections.IIterable`1", "System.Collections.Generic.IEnumerable`1"
    INTERFACE "Windows.Foundation.Collections.IVector`1", "System.Collections.Generic.IList`1"
    INTERFACE "Windows.Foundation.Collections.IVectorView`1", "System.Collections.Generic.IReadOnlyList`1"
    INTERFACE "Windows.Foundation.Collections.IMap`2", "System.Collections.Generic.IDictionary`2"
    INTERFACE "Windows.Foundation.Collections.IMapView`2", "System.Collections.Generic.IReadOnlyDictionary`2"
    INTERFACE "Windows.Foundation.Collections.IKeyValuePair`2", "System.Collections.Generic.KeyValuePair`2"
    + some more types in Windows.UI.Xaml namespace

    The list is subject to change before the final list is published and officially documented! (This is not official documentation)

    Note that some types have the same name, but are used from .NET assemblies (e.g. System.Runtime.WindowsRuntime.dll), some of them flip struct to class and vice versa.

    I hope it helps,
    -Karel Zikmund
    (Developer on CLR team)

    Tuesday, March 6, 2012 7:57 PM

All replies

  • Hi Carlo,

    I am looking into this now.  Are you looking for a table of the mapping between WinRT types and how it maps to the .NET type? e.g.

    Windows.Foundation.Collections.IIterable<T> maps to System.Collections.Generic.IEnumerable<T>

    Are you looking for a programmatic way to do this with the only requirement that you can't use metadatareader interfaces?

    much appreciated,

    Mike Wong

    Microsoft Developer Support

    Tuesday, March 6, 2012 6:39 PM
    Moderator
  • Hi Carlo,

    I am looking into this now.  Are you looking for a table of the mapping between WinRT types and how it maps to the .NET type? e.g.

    Windows.Foundation.Collections.IIterable<T> maps to System.Collections.Generic.IEnumerable<T>

    Are you looking for a programmatic way to do this with the only requirement that you can't use metadatareader interfaces?

    much appreciated,

    Yep. We use a library called "Cecil" to read PE executables; so what I'm looking for is the exact list of WINMD specific types that translate to .NET. thanks,

    Carlo Kok


    Carlo Kok

    Tuesday, March 6, 2012 7:09 PM
  • Hello Carlo,

    CLR team is working on documentation of the projections (aka mapping between WinRT and .NET types).

    You can get the full list of mapped types yourself by creating a C# program that will have typeof(WinRTType1); typeof(WinRTType2); etc. You can use ildasm (with /met argument) on .winmd files to get list of all public WinRT types.

    Here is a list of most of the projected types from our source code. DISCLAIMER: The list is not guaranteed, verified and may not be final for .NET 4.5 RTM!!!

    CLASS "Windows.Foundation.Metadata.AttributeUsageAttribute", "System.AttributeUsageAttribute"
    ENUM "Windows.Foundation.Metadata.AttributeTargets", "System.AttributeTargets"
    STRUCT "Windows.UI.Color", "Windows.UI.Color"
    STRUCT "Windows.Foundation.DateTime", "System.DateTimeOffset"
    DELEGATE "Windows.Foundation.EventHandler`1", "System.EventHandler`1"
    STRUCT "Windows.Foundation.EventRegistrationToken", "System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken
    STRUCT "Windows.Foundation.HResult", "System.Exception"
    INTERFACE "Windows.Foundation.IReference`1", "System.Nullable`1"
    STRUCT "Windows.Foundation.Point", "Windows.Foundation.Point"
    STRUCT "Windows.Foundation.Rect", "Windows.Foundation.Rect"
    STRUCT "Windows.Foundation.Size", "Windows.Foundation.Size"
    STRUCT "Windows.Foundation.TimeSpan", "System.TimeSpan"
    RUNTIMECLASS "Windows.Foundation.Uri", "System.Uri"
    INTERFACE "Windows.Foundation.IClosable", "System.IDisposable"
    INTERFACE "Windows.Foundation.Collections.IIterable`1", "System.Collections.Generic.IEnumerable`1"
    INTERFACE "Windows.Foundation.Collections.IVector`1", "System.Collections.Generic.IList`1"
    INTERFACE "Windows.Foundation.Collections.IVectorView`1", "System.Collections.Generic.IReadOnlyList`1"
    INTERFACE "Windows.Foundation.Collections.IMap`2", "System.Collections.Generic.IDictionary`2"
    INTERFACE "Windows.Foundation.Collections.IMapView`2", "System.Collections.Generic.IReadOnlyDictionary`2"
    INTERFACE "Windows.Foundation.Collections.IKeyValuePair`2", "System.Collections.Generic.KeyValuePair`2"
    + some more types in Windows.UI.Xaml namespace

    The list is subject to change before the final list is published and officially documented! (This is not official documentation)

    Note that some types have the same name, but are used from .NET assemblies (e.g. System.Runtime.WindowsRuntime.dll), some of them flip struct to class and vice versa.

    I hope it helps,
    -Karel Zikmund
    (Developer on CLR team)

    Tuesday, March 6, 2012 7:57 PM
  • Thanks!

    Carlo Kok

    Wednesday, March 7, 2012 10:49 PM