Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases of type 'dynamic' cannot be accessed directly #2610

Closed
lukoerfer opened this issue Aug 21, 2019 · 4 comments

Comments

@lukoerfer
Copy link

commented Aug 21, 2019

What You Are Seeing?

Working on an addin I introduced an alias property with the return type dynamic. But when referencing to the alias in the build script, it was not possible to directly get / set dynamic sub properties of the alias property, because Cake terminated with an error:

error CS1061: 'object' does not contain a definition for 'SomeDynamicProperty' and no accessible extension method 'SomeDynamicProperty' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

What is Expected?

I expected Cake to support this use case, because it is supported by the language C# in general.

What version of Cake are you using?

I used v0.34.1 and also used the -experimental switch.

Are you running on a 32 or 64 bit system?

64 bit system

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

I've created an example setup with a minimal addin and a minimal build script.

Addin code:

public static class DynamicAliases
{
    [CakePropertyAlias(Cache = true)]
    public static dynamic SomeDynamic(this ICakeContext context)
    {
        return new ExpandoObject();
    }
}

Build script:

#r "Cake.DynamicAliases\bin\Debug\netstandard2.0\Cake.DynamicAliases.dll"

// This fails
SomeDynamic.SomeDynamicProperty = "Value";

// But this works
dynamic someDynamic = SomeDynamic;
someDynamic.SomeDynamicProperty = "Value";

If it would help, I could create a repository for this setup.

@kcamp

This comment has been minimized.

Copy link
Collaborator

commented Aug 21, 2019

The script generation process doesn't appear to account for this, but is an easy fix. I can have a PR to address it in the next day or so.

@devlead devlead added this to the v0.35.0 milestone Aug 21, 2019
@devlead devlead added the Bug label Aug 21, 2019
@devlead

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

@kcamp yes need to check for presence of DynamicAttribute, I'll assign the issue to you then 👍

@kcamp

This comment has been minimized.

Copy link
Collaborator

commented Aug 21, 2019

Sound good.

devlead added a commit that referenced this issue Aug 22, 2019
@devlead

This comment has been minimized.

Copy link
Member

commented Aug 22, 2019

Fixed by #2612

@devlead devlead closed this Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.