GithubHelp home page GithubHelp logo

mikehillberg / middleweight-reflection Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 104 KB

.Net library to read .Net Assembly and Windows WinMD metadata files, based on System.Reflection.Metadata

License: MIT License

C# 100.00%

middleweight-reflection's People

Contributors

asklar avatar mikehillberg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

asklar

middleweight-reflection's Issues

Base classes outside the current assembly are not properly resolved

Setup:

  • Runtime component that exports a MyUserControl (inherits from Windows.UI.Xaml.UserControl)
  • context.LoadAssemblyFromPath( ) called once for Windows.winmd, and once for RuntimeComponent.winmd
  • find the MyUserControl type (e.g. iterate via winmd.GetAllTypes())

Result:

calling type.GetBaseType() returns null instead of Windows.UI.Xaml.UserControl

Expected:

properly resolves to the type in the other assembly that's loaded in the context

How to obtain the Windows.Foundation type for a given .net projected type?

When a parameter type or return type is something like Windows.Foundation.Collections.IVector`1, it gets reported back as its .net projection System.Collections.Generic.IList`1, even when the load context has the "use winrt projection" option set.

Is there a way to map back to the WF type, or do I have to keep a mapping of the type names and convert it in my app?

MrType Equals doesn't have value semantics

prop
{MrProperty: ContentControl.Content}
Attributes: None
DeclaringType: {Windows.UI.Xaml.Controls.ContentControl}
Definition: {System.Reflection.Metadata.PropertyDefinition}
DefinitionHandle: {System.Reflection.Metadata.PropertyDefinitionHandle}
Getter: {MrMethod: ContentControl.get_Content}
Setter: {MrMethod: ContentControl.put_Content}

contentProperty
{MrProperty: ContentControl.Content}
Attributes: None
DeclaringType: {Windows.UI.Xaml.Controls.ContentControl}
Definition: {System.Reflection.Metadata.PropertyDefinition}
DefinitionHandle: {System.Reflection.Metadata.PropertyDefinitionHandle}
Getter: {MrMethod: ContentControl.get_Content}
Setter: {MrMethod: ContentControl.put_Content}

prop == contentProperty
false

*Collection types return empty methods

// get a MrType of WUX.Media.Animation.TransitionCollection
var t = LoadContext.GetType("Windows.UI.Xaml.Media.Animation.TransitionCollection");
t.GetMethodsAndConstructors(out var methods, out var ctors);

var insertAt = methods.First(m => m.GetName() == "InsertAt");   

This throws, the methods array is empty

Can't resolve custom attributes outside of the target assembly

I have a type/method that I've added [deprecated("foo", deprecate, 1)] to.

ca.GetArguments(out var fixedArgs, out var namedArgs);

both argument lists are empty, because it's trying to resolve the custom attribute in the same Assembly where it is applied to.

The code correctly identifies the need to resolve DeprecationType in the Windows.FoundationContract assembly, but this is marked as a fake assembly, so it calls RaiseFakeTypeRequired, but the FakeTypeRequired event handler is null.

Update:
The solution is to do something like:

            context.FakeTypeRequired += (sender, e) => {
                var ctx = sender as MrLoadContext;
                if (e.AssemblyName == "Windows.Foundation.FoundationContract")
                {
                    e.ReplacementType = ctx.GetTypeFromAssembly(e.TypeName, "Windows");
                }
            };

This should probably be a default though, or at least documented :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.