-
Notifications
You must be signed in to change notification settings - Fork 458
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
Support for .NET Core 3.x #517
Support for .NET Core 3.x #517
Conversation
I can't seem to be able to build solution becase of errors in other projects. But the 2 new ones should be ok |
@ltines I didn’t know you had anything ready. |
@generik0 The project builds but I can't make the whole solution to build on mine MSVS due to errors in other projects - i guess its becase of some missing setup. but CI seems to be building fine. Can you give it a try and build it? |
@ltines can you give me access to your repo. Looks like MS have change .cproj format for iconurl Very strange though. I build multiple projects with the same property.. "PackageIconUrl". Strange it isn't working here. |
@jonorossi can you please make a branch the PR can land to? Or do you wnt it directly into master from the PR? |
I don't think the errors are related to my changes |
@jonorossi ok to add NU5048 to no warn? |
@ltines i think you (or someone) needs to add uTest to the sln for the extensions. Maybe look at the aspnetcore facility for inspiration. I have a feeling, no tests, no merge.. (Kust the messenger here) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ltines a quick review for you :-)
(Update)
@ltinies I see the web review mechanism didn’t always catch my line selection. I will try to fix tomorrow
|
||
public Burden GetCachedInstance(ComponentModel model, ScopedInstanceActivationCallback createInstance) | ||
{ | ||
if(model.Configuration.Attributes.Get(NetCoreTransientMarker) == Boolean.TrueString ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line for "{"?
src/Castle.Windsor.Extensions.MsDependencyInjection/NetCoreScopeAccessor.cs
Outdated
Show resolved
Hide resolved
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// The MIT License (MIT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonorossi Copyright (c) 2016 Volosoft in Castle code? Is it needed since Volosoft is MIT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to give them credit since i copied the source as a whole
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ltines you can't do that, the author/copyright-holder of the code is the only person allowed to relicense it, and we like to keep all of Castle under the Apache 2.0 license otherwise it gets complicated. We'd need them to relicense it.
The "copyright Castle Project" part effectively is short for "copyright Castle Project contributors" as no copyright assignment is made. OpenStreetMap a lot of time has the same shorthand for "copyright OpenStreetMap contributors".
|
||
public static string OriginalComponentName(string uniqueComponentName) | ||
{ | ||
if(uniqueComponentName == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yuou must have {} for each block
https://github.com/castleproject/Home/blob/master/coding-standards.md#blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
private static string UniqueComponentName(Microsoft.Extensions.DependencyInjection.ServiceDescriptor service) | ||
{ | ||
return | ||
(service.ImplementationType?.FullName ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they dont want c-style ??
https://github.com/castleproject/Home/blob/master/coding-standards.md#c-style-code
} | ||
|
||
current.Value = parent; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab indentaion?
|
||
|
||
public void Dispose() | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab indentaion
src/Castle.Windsor.Extensions.MsDependencyInjection/NetCoreRootScopeAccessor.cs
Outdated
Show resolved
Hide resolved
{ | ||
this.parent = parent; | ||
scopeCache = new ScopeCache(); | ||
Nesting = (parent?.Nesting ?? 0) + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sure if C-style it prefered here:
https://github.com/castleproject/Home/blob/master/coding-standards.md#c-style-code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
|
||
|
||
public virtual NetCoreRootScope RootScope => rootScope; | ||
public virtual int Nesting {get; private set;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this "Nesting" used for? i dont see anything but setting for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. It was used for debugging .NET Core scope nesting
@generik0 cheers for the review - hopefully fixed all the coding style issues. With the UT its a good point. The problem though is - there is a project for UT but it needs to use xUnit because its based on .NET Core specification tests. What's the preferred UT framework here? |
I think it is xUnit in the Castle. Check out the aspnetcore tests :-) |
@generik0 aspnetcore is using NUnit. Anyway managed to build it and tests are passing |
Good to know, and great work dude... |
Is there a nuget package for that? |
The contributing.md says we should be able to get from a nuget feed: So until @jonorossi is available, and makes a branch/accepts PR + pre-release, I think you need to grab from build server and provide using local nuget folder: |
The pre-release feed has been discontinued.
|
Fixes wrong order of initializing options
Sorry, took few weeks but finally tracked down the issue. Can you try latest? |
Transient components get released when |
I for sure will today. Thank you for taking a look. The latest version looks to be v0.0.674 |
It's unfortunately still broken. I have attached a screenshot of what I'm referring to, the options.Conventions seems to be null, it is not when using the volosoft integration. I tested against v0.0.674 of Castle.Windsor.Extensions.DependencyInjection. |
@robsonj So after a lot more digging through aspnetcore and extensions and windsor sources the problem is:
Does anybody has better idea how to register the same class multiple times for different services without default? |
Please forgive me, I didn't read a lot of the thread, so maybe I'm totally off, but would named instances help? container.Register(
Component.For<Interface1>().ImplementedBy<Implementation>().Named(Guid.NewGuid().ToString()),
Component.For<Interface2>().ImplementedBy<Implementation>().Named(Guid.NewGuid().ToString())
);
var s1 = container.Resolve<Interface1>();
var s2 = container.Resolve<Interface2>(); |
it's already using named instances but has other limitations. The problem is to keep the resolved order the same as registered regardless of whether it's default, named or fallback. Anyway i finally cracked it. @robsonj have a look pls - it resolves Options setup in right order and it passes all spec tests. Had to override @jonorossi i did some renaming to remove NetCore prefix |
Thankyou @ltines , I checked the Options and everything looks great now! Ready for a release version from my perspective :-) |
@Itines, Will the implementation work with net core 2.x? Or only 3+? Maybe we should try to get a prerelease out? |
AFAIK only 3.x since between 2 and 3 they changed the DI. |
@jonorossi Any chances of building a pre-release to nuget.org on this branch. It will be easies for many to test....? |
....Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj
Outdated
Show resolved
Hide resolved
src/Castle.Windsor.Extensions.DependencyInjection/Extensions/HostBuilderExtensions.cs
Show resolved
Hide resolved
src/Castle.Windsor.Extensions.DependencyInjection/Extensions/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
....Windsor.Extensions.DependencyInjection/Castle.Windsor.Extensions.DependencyInjection.csproj
Outdated
Show resolved
Hide resolved
src/Castle.Windsor.Extensions.DependencyInjection/Extensions/WindsorExtensions.cs
Outdated
Show resolved
Hide resolved
...stle.Windsor.Extensions.DependencyInjection/SubSystems/DependencyInjectionNamingSubsystem.cs
Show resolved
Hide resolved
...stle.Windsor.Extensions.DependencyInjection/SubSystems/DependencyInjectionNamingSubsystem.cs
Outdated
Show resolved
Hide resolved
src/Castle.Windsor.Extensions.DependencyInjection/Extensions/WindsorExtensions.cs
Outdated
Show resolved
Hide resolved
@ltines Once you move the docs into the right place, I'll merge this PR and publish a prerelease build for everyone to test out. |
Done. Thanks @jonorossi for the help. |
Merged and v5.1.0-beta001 published to nuget.org. Thanks. |
/// <summary> | ||
/// Naming subsystem based on DefaultNamingSubSystem but GetHandlers returns handlers in registration order | ||
/// </summary> | ||
internal class DependencyInjectionNamingSubsystem : DefaultNamingSubSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this sub-system to an existing container wipes out all its components. Furthermore, the sub-system looks virtually identical to the base implementation.
Can someone tell me why this is needed for .NET core 3.1? Is there something different about .NET core 3.1 that requires this particular class? I've compiled my own version that doesn't include this sub-system, just to test, and it seems to work the same way regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @robertcoltheart
I tried removing the subsystem when i refactored some of this code. From what I remembered it made all or many if the unit tests fail.
If you look at the new implementation you on master you will see you can override the sub system.
Could you please make a new issue, and reference the current implementation and we can look deeper into it together?
Adds support for .NET Core Dependency Injection interfaces (https://github.com/dotnet/extensions/):
IServiceProviderFactory
to provide Castle Windsor provider asIServiceProvider
implementationServiceScopeFactory
which begins Castle Windsor scopeIServiceCollection
will be registered with the containerThere are different semantics for lifestyles between MS DI and Castle Windsor:
Fixes #493