Skip to content

InvokeGet with static context fails #26

@tpluscode

Description

@tpluscode

I'm migrating an older projects to .NET Standard. Previously I used ImpromputInterface:

Impromptu.InvokeGet(type.WithStaticContext(), "Context");

Where the type is for example a nested private class within a test fixture:

public class ContextResolverTests
{
    private class GenericType
    {
        private static string Context => "Text";
    }
}

Now I want to target netstandard1.5 so I replaced the original implementation with Dynamitey

var staticContext = InvokeContext.CreateStatic;
return Dynamic.InvokeGet(staticContext(type), "Context");

And it stopped working!

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : 
   'JsonLD.Entities.Tests.ContextResolverTests.GenericType' does not contain a definition for 'Context'

Apparently the class has to be public and cannot be nested. Here's my repository stripped down. I removed everything, all unnecessary code and replaced paket with plain nuget references, to no avail.

does-not-work.zip

But the real kicker is that I tried to reproduce this from scratch and was completely unable to get the same effect. What is going on?

works.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions