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

Added a failing test demonstrating the issue #451. #452

Merged
merged 1 commit into from
Feb 18, 2022

Conversation

yallie
Copy link
Contributor

@yallie yallie commented Feb 9, 2022

Uncomment the CompilerGeneratedAttribute, and the test will fail.

}

// generated code from App.settings
//[System.Runtime.CompilerServices.CompilerGenerated]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute makes Settings class unresolvable.

@yallie
Copy link
Contributor Author

yallie commented Feb 9, 2022

By the way, the filter for CompilerGeneratedAttribute still allows registering anonymous classes, i.e.

// settings is compiler-generated
var settings = new
{
    Path = @"c:\System",
    AppName = @"command.com",
};

container.RegisterInstance<object>(settings, serviceKey: "settings");

// it works nonetheless :)
var x = container.Resolve<object>(serviceKey: "settings");
Assert.AreSame(x, settings);

Although it would be much more useful if anonymous classes could implement interfaces.

@dadhi
Copy link
Owner

dadhi commented Feb 9, 2022

Although it would be much more useful if anonymous classes could implement interfaces.

Yep.. works just great in scala or java.

@dadhi dadhi merged commit 66efab1 into dadhi:master Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants