-
Notifications
You must be signed in to change notification settings - Fork 933
WIP - Replace IObjectsFactory with IServiceProvider interface #1793
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
Open
maca88
wants to merge
16
commits into
nhibernate:master
Choose a base branch
from
maca88:IServiceProvider
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4aca182
Replace IObjectsFactory with IServiceProvider interface
maca88 98485e0
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte 4f5cae4
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte ae4d2b4
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte c52ec3b
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte d72268f
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte 131830b
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte 79b5c5a
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte e61274a
fixup! Replace IObjectsFactory with IServiceProvider interface
fredericDelaporte 2b2950c
Removed registration logic from DefaultServiceProvider and renamed it…
maca88 b256937
Added a fallback mechanism for internal types when the IoC container …
maca88 8cc22f8
Added the fallback also for external types
maca88 b31157a
Renamed GetInstance to GetMandatoryService
maca88 cf3bbf6
Fixed GetService usages
maca88 357b628
Regenerate async
maca88 d52629b
Upgrade async generator to 0.8.2.10
maca88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/NHibernate.Test/Bytecode/ActivatorServiceProviderFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using NHibernate.Bytecode; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.Bytecode | ||
{ | ||
[TestFixture] | ||
public class ActivatorServiceProviderFixture | ||
{ | ||
public class WithOutPublicParameterLessCtor | ||
{ | ||
public string Something { get; set; } | ||
protected WithOutPublicParameterLessCtor() { } | ||
|
||
public WithOutPublicParameterLessCtor(string something) | ||
{ | ||
Something = something; | ||
} | ||
} | ||
|
||
public class PublicParameterLessCtor | ||
{ | ||
} | ||
|
||
protected virtual IServiceProvider GetServiceProvider() | ||
{ | ||
return new ActivatorServiceProvider(); | ||
} | ||
|
||
[Test] | ||
public void CreateInstanceDefCtor() | ||
{ | ||
var sp = GetServiceProvider(); | ||
Assert.Throws<ArgumentNullException>(() => sp.GetService(null)); | ||
Assert.Throws<MissingMethodException>(() => sp.GetService(typeof(WithOutPublicParameterLessCtor))); | ||
var instance = sp.GetService(typeof(PublicParameterLessCtor)); | ||
Assert.That(instance, Is.Not.Null); | ||
Assert.That(instance, Is.InstanceOf<PublicParameterLessCtor>()); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using NHibernate.Bytecode; | ||
using NUnit.Framework; | ||
using Environment = NHibernate.Cfg.Environment; | ||
|
||
namespace NHibernate.Test.CfgTest | ||
{ | ||
[TestFixture] | ||
public class CustomServiceProviderTest | ||
{ | ||
private class MyServiceProvider : IServiceProvider | ||
{ | ||
public object GetService(System.Type serviceType) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
private class InvalidServiceProvider | ||
{ | ||
} | ||
private class InvalidNoCtorServiceProvider : MyServiceProvider | ||
{ | ||
public InvalidNoCtorServiceProvider(string pizza) {} | ||
} | ||
|
||
[Test] | ||
public void WhenNoShortCutUsedThenCanBuildServiceProvider() | ||
{ | ||
var properties = new Dictionary<string, string> { { Environment.PropertyBytecodeProvider, typeof(MyServiceProvider).AssemblyQualifiedName } }; | ||
Assert.That(() => Environment.BuildServiceProvider(properties), Throws.Nothing); | ||
} | ||
|
||
[Test] | ||
public void WhenNoShortCutUsedThenCanBuildInstanceOfConfiguredServiceProvider() | ||
{ | ||
var properties = new Dictionary<string, string> { { Environment.PropertyServiceProvider, typeof(MyServiceProvider).AssemblyQualifiedName } }; | ||
Assert.That(Environment.BuildServiceProvider(properties), Is.InstanceOf<MyServiceProvider>()); | ||
} | ||
|
||
[Test] | ||
public void WhenInvalidThenThrow() | ||
{ | ||
var properties = new Dictionary<string, string> { { Environment.PropertyServiceProvider, typeof(InvalidServiceProvider).AssemblyQualifiedName } }; | ||
Assert.That(() => Environment.BuildServiceProvider(properties), Throws.TypeOf<HibernateServiceProviderException>()); | ||
} | ||
|
||
[Test] | ||
public void WhenNoDefaultCtorThenThrow() | ||
{ | ||
var properties = new Dictionary<string, string> { { Environment.PropertyServiceProvider, typeof(InvalidNoCtorServiceProvider).AssemblyQualifiedName } }; | ||
Assert.That(() => Environment.BuildServiceProvider(properties), Throws.TypeOf<HibernateServiceProviderException>() | ||
.And.InnerException.Message.Contains("constructor was not found")); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.