diff --git a/build.cake b/build.cake index dfcda3596..3fd6fdbe0 100644 --- a/build.cake +++ b/build.cake @@ -78,6 +78,7 @@ var packageWhitelist = new[] { "Splat", "Splat.Autofac", + "Splat.DryIoc", "Splat.SimpleInjector", }; @@ -85,6 +86,7 @@ var packageTestWhitelist = new[] { "Splat.Tests", "Splat.Autofac.Tests", + "Splat.DryIoc.Tests", "Splat.SimpleInjector.Tests", }; diff --git a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj index 110463ba2..e792b4c54 100644 --- a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj +++ b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Splat.DryIoc.Tests/DependencyResolverTests.cs b/src/Splat.DryIoc.Tests/DependencyResolverTests.cs new file mode 100644 index 000000000..301b3d8f5 --- /dev/null +++ b/src/Splat.DryIoc.Tests/DependencyResolverTests.cs @@ -0,0 +1,127 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using DryIoc; +using ReactiveUI; +using Shouldly; +using Xunit; + +namespace Splat.DryIoc.Tests +{ + /// + /// Tests to show the works correctly. + /// + public class DependencyResolverTests + { + /// + /// Shoulds the resolve views. + /// + [Fact] + public void DryIocDependencyResolver_Should_Resolve_Views() + { + var container = new Container(); + container.Register, ViewOne>(); + container.Register, ViewTwo>(); + container.UseDryIocDependencyResolver(); + + var viewOne = Locator.Current.GetService(typeof(IViewFor)); + var viewTwo = Locator.Current.GetService(typeof(IViewFor)); + + viewOne.ShouldNotBeNull(); + viewOne.ShouldBeOfType(); + viewTwo.ShouldNotBeNull(); + viewTwo.ShouldBeOfType(); + } + + /// + /// Shoulds the resolve views. + /// + [Fact] + public void DryIocDependencyResolver_Should_Resolve_Named_View() + { + var container = new Container(); + container.Register, ViewTwo>(serviceKey: "Other"); + container.UseDryIocDependencyResolver(); + + var viewTwo = Locator.Current.GetService(typeof(IViewFor), "Other"); + + viewTwo.ShouldNotBeNull(); + viewTwo.ShouldBeOfType(); + } + + /// + /// Shoulds the resolve view models. + /// + [Fact] + public void DryIocDependencyResolver_Should_Resolve_View_Models() + { + var container = new Container(); + container.Register(); + container.Register(); + container.UseDryIocDependencyResolver(); + + var vmOne = Locator.Current.GetService(); + var vmTwo = Locator.Current.GetService(); + + vmOne.ShouldNotBeNull(); + vmTwo.ShouldNotBeNull(); + } + + /// + /// Shoulds the resolve screen. + /// + [Fact] + public void DryIocDependencyResolver_Should_Resolve_Screen() + { + var builder = new Container(); + builder.Register(Reuse.Singleton); + builder.UseDryIocDependencyResolver(); + + var screen = Locator.Current.GetService(); + + screen.ShouldNotBeNull(); + screen.ShouldBeOfType(); + } + + /// + /// Shoulds register ReactiveUI binding type converters. + /// + [Fact] + public void DryIocDependencyResolver_Should_Register_ReactiveUI_BindingTypeConverters() + { + // Invoke RxApp which initializes the ReactiveUI platform. + var scheduler = RxApp.MainThreadScheduler; + var container = new Container(); + container.UseDryIocDependencyResolver(); + + var converters = container.Resolve>().ToList(); + + converters.ShouldNotBeNull(); + converters.ShouldContain(x => x.GetType() == typeof(StringConverter)); + converters.ShouldContain(x => x.GetType() == typeof(EqualityTypeConverter)); + } + + /// + /// Shoulds register ReactiveUI creates command bindings. + /// + [Fact] + public void DryIocDependencyResolver_Should_Register_ReactiveUI_CreatesCommandBinding() + { + // Invoke RxApp which initializes the ReactiveUI platform. + var scheduler = RxApp.MainThreadScheduler; + var container = new Container(); + container.UseDryIocDependencyResolver(); + + var converters = container.Resolve>().ToList(); + + converters.ShouldNotBeNull(); + converters.ShouldContain(x => x.GetType() == typeof(CreatesCommandBindingViaEvent)); + converters.ShouldContain(x => x.GetType() == typeof(CreatesCommandBindingViaCommandParameter)); + } + } +} diff --git a/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs b/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs new file mode 100644 index 000000000..11a81fc76 --- /dev/null +++ b/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using ReactiveUI; + +namespace Splat.DryIoc.Tests +{ + /// + /// An implementation. + /// + /// + public class MockScreen : IScreen + { + /// + /// Gets the Router associated with this Screen. + /// + public RoutingState Router { get; } + } +} diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs b/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs new file mode 100644 index 000000000..ecf61ae4d --- /dev/null +++ b/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using ReactiveUI; + +namespace Splat.DryIoc.Tests +{ + /// + /// View Model One. + /// + /// + /// + public class ViewModelOne : ReactiveObject, IRoutableViewModel + { + /// + public string UrlPathSegment { get; } + + /// + public IScreen HostScreen { get; } + } +} diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs b/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs new file mode 100644 index 000000000..3dbfade1d --- /dev/null +++ b/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using ReactiveUI; + +namespace Splat.DryIoc.Tests +{ + /// + /// View Model Two. + /// + /// + /// + public class ViewModelTwo : ReactiveObject, IRoutableViewModel + { + /// + public string UrlPathSegment { get; } + + /// + public IScreen HostScreen { get; } + } +} diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs b/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs new file mode 100644 index 000000000..4dbcf91b0 --- /dev/null +++ b/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using ReactiveUI; + +namespace Splat.DryIoc.Tests +{ + /// + /// View One. + /// + /// + public class ViewOne : IViewFor + { + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (ViewModelOne)value; + } + + /// + public ViewModelOne ViewModel { get; set; } + } +} diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs b/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs new file mode 100644 index 000000000..501b0f212 --- /dev/null +++ b/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using ReactiveUI; + +namespace Splat.DryIoc.Tests +{ + /// + /// View Two. + /// + /// + [ViewContract("Other")] + public class ViewTwo : IViewFor + { + /// + object IViewFor.ViewModel + { + get => ViewModel; + set => ViewModel = (ViewModelTwo)value; + } + + /// + public ViewModelTwo ViewModel { get; set; } + } +} diff --git a/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj new file mode 100644 index 000000000..69c4b3b3f --- /dev/null +++ b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj @@ -0,0 +1,25 @@ + + + + netcoreapp2.1;net472 + + false + $(NoWarn);1591;CA1707;SA1633 + + + + + + + + + + + + + + Always + + + + diff --git a/src/Splat.DryIoc/DryIocDependencyResolver.cs b/src/Splat.DryIoc/DryIocDependencyResolver.cs new file mode 100644 index 000000000..98afdb74b --- /dev/null +++ b/src/Splat.DryIoc/DryIocDependencyResolver.cs @@ -0,0 +1,107 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using DryIoc; + +namespace Splat.DryIoc +{ + /// + /// DryIoc implementation for . + /// https://bitbucket.org/dadhi/dryioc/wiki/Home. + /// + /// + public class DryIocDependencyResolver : IMutableDependencyResolver + { + private Container _container; + + /// + /// Initializes a new instance of the class. + /// + /// The container. + public DryIocDependencyResolver(Container container = null) + { + _container = container ?? new Container(); + } + + /// + public object GetService(Type serviceType, string contract = null) => + string.IsNullOrEmpty(contract) + ? _container.Resolve(serviceType, IfUnresolved.ReturnDefault) + : _container.Resolve(serviceType, contract, IfUnresolved.ReturnDefault); + + /// + public IEnumerable GetServices(Type serviceType, string contract = null) => + string.IsNullOrEmpty(contract) + ? _container.ResolveMany(serviceType) + : _container.ResolveMany(serviceType, serviceKey: contract); + + /// + public void Register(Func factory, Type serviceType, string contract = null) + { + if (string.IsNullOrEmpty(contract)) + { + _container.UseInstance(serviceType, factory(), IfAlreadyRegistered.AppendNewImplementation); + } + else + { + _container.UseInstance(serviceType, factory(), IfAlreadyRegistered.AppendNewImplementation, serviceKey: contract); + } + } + + /// + public void UnregisterCurrent(Type serviceType, string contract = null) + { + if (string.IsNullOrEmpty(contract)) + { + _container.Unregister(serviceType); + } + else + { + _container.Unregister(serviceType, contract); + } + } + + /// + public void UnregisterAll(Type serviceType, string contract = null) + { + if (string.IsNullOrEmpty(contract)) + { + _container.Unregister(serviceType, condition: x => x.ImplementationType == serviceType); + } + else + { + _container.Unregister(serviceType, contract, condition: x => x.ImplementationType == serviceType); + } + } + + /// + public IDisposable ServiceRegistrationCallback(Type serviceType, string contract, Action callback) + { + throw new NotImplementedException(); + } + + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Disposes of the instance. + /// + /// Whether or not the instance is disposing. + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + _container?.Dispose(); + _container = null; + } + } + } +} diff --git a/src/Splat.DryIoc/GlobalSuppressions.cs b/src/Splat.DryIoc/GlobalSuppressions.cs new file mode 100644 index 000000000..f141fbb88 --- /dev/null +++ b/src/Splat.DryIoc/GlobalSuppressions.cs @@ -0,0 +1,88 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1001:Commas should not be preceded by whitespace", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1004:DocumentationLinesMustBeginWithSingleSpace", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1005:Single line comments should begin with single space", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1108:Block statements should not contain embedded comments", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1009:Closing parenthesis should be spaced correctly", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1025:CodeMustNotContainMultipleWhitespaceInARow", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1028:Code should not contain trailing whitespace", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1106:Code should not contain empty statements", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1111:ClosingParenthesisMustBeOnLineOfLastParameter", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1113:CommaMustBeOnSameLineAsPreviousParameter", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1115:ParameterMustFollowComma", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1116:Split parameters should start on line after declaration", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:Parameters should be on same line or separate lines", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:ParameterMustNotSpanMultipleLines", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1119:Statement should not use unnecessary par", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1120:Commends should contain text", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1121:UseBuiltInTypeAlias", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1122:UseStringEmptyForEmptyStrings", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1124:Do not use regions", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1127:Generic type constraints should be on their own line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1128:Put constructor initializers on their own line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1129:Do not use default value type constructor", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1132:Do not combine fields", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1135:Using directives should be qualified", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1136:Enum values should be on separate lines", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1137:Elements should have the same indentation", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements should be ordered by access", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:Constants should appear before fields", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1204:Static elements should appear before instance elements", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1210:Using directives should be ordered alphabetically by namespace", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1211:UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1214:Readonly fields should appear before non-readonly fields", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1216:Using static directives should be placed at the correct location", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1314:Type parameter names should begin with T", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1408:Conditional expressions should declare precedence", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501:Statement should not be on a single line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1502:Element should not be on a single line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces should not be omitted", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1506:ElementDocumentationHeadersMustNotBeFollowedByBlankLine", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1507:CodeMustNotContainMultipleBlankLinesInARow", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1508:ClosingBracesMustNotBePrecededByBlankLine", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1510:Chained statement blocks should not be preceded by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:Single-line comments should not be followed by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1513:Closing brace should be followed by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1514:Element documentation header should be preceded by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1515:Single-line comment should be preceded by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1516:Elements should be separated by blank line", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1520:Use braces consistently", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1519:Braces should not be omitted from multi-line child statement", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1604:Element documentation should have summary", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1614:Element parameter documentation should have text", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1615:Element return value should be documented", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1617:VoidReturnValueMustNotBeDocumented", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1618:Generic type parameters should be documented", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation should match accessors", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1625:Element documentation should not be copied and pasted", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1626:SingleLineCommentsMustNotUseDocumentationStyleSlashes", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:Documentation text should end with a period", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:The file header is missing or not located at the top of the file", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1636:FileHeaderCopyrightTextMustMatch", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:Constructor summary documentation should begin with standard text", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "Third Party Dependency")] + +[assembly: SuppressMessage("Style", "RCS1055", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Style", "RCS1201", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Style", "RCS1211", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Style", "RCS1001:Add braces (when expression spans over multiple lines).", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Style", "RCS1037:Remove trailing white-space.", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Style", "RCS1003:Add braces to if-else (when expression spans over multiple lines).", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Maintainability", "RCS1139:Add summary element to documentation comment.", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Redundancy", "RCS1163:Unused parameter.", Justification = "Third Party Dependency")] + +[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Third Party Dependency")] +[assembly: SuppressMessage("Design", "CA1801:Parameter bodyExpr of method TryCompile is never used. Remove the parameter or use it in the method body", Justification = "Third Party Dependency")] diff --git a/src/Splat.DryIoc/Splat.DryIoc.csproj b/src/Splat.DryIoc/Splat.DryIoc.csproj new file mode 100644 index 000000000..18ae62fd2 --- /dev/null +++ b/src/Splat.DryIoc/Splat.DryIoc.csproj @@ -0,0 +1,15 @@ + + + + netstandard2.0 + + + + + + + + + + + diff --git a/src/Splat.DryIoc/SplatDryIocExtensions.cs b/src/Splat.DryIoc/SplatDryIocExtensions.cs new file mode 100644 index 000000000..f8597d26e --- /dev/null +++ b/src/Splat.DryIoc/SplatDryIocExtensions.cs @@ -0,0 +1,25 @@ +// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved. +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Text; +using DryIoc; + +namespace Splat.DryIoc +{ + /// + /// Extension methods for the DryIoc adapter. + /// + public static class SplatDryIocExtensions + { + /// + /// Initializes an instance of that overrides the default . + /// + /// The container. + public static void UseDryIocDependencyResolver(this Container container) => + Locator.CurrentMutable = new DryIocDependencyResolver(container); + } +} diff --git a/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj b/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj index 30127b245..1b8bbed18 100644 --- a/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj +++ b/src/Splat.SimpleInjector.Tests/Splat.SimpleInjector.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Splat.sln b/src/Splat.sln index 51d070d2f..15d1ed48c 100644 --- a/src/Splat.sln +++ b/src/Splat.sln @@ -23,7 +23,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Splat.SimpleInjector.Tests" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Splat.NLog", "Splat.NLog\Splat.NLog.csproj", "{24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Splat.Log4Net", "Splat.Log4Net\Splat.Log4Net.csproj", "{E6EA3895-DB97-43A0-8140-EB4789796EEB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Splat.DryIoc", "Splat.DryIoc\Splat.DryIoc.csproj", "{941DAAE2-EDCA-41A8-93FF-0C4178639A47}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Splat.DryIoc.Tests", "Splat.DryIoc.Tests\Splat.DryIoc.Tests.csproj", "{E1777877-6F56-46D0-8747-4BB921ED4C8E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Splat.Log4Net", "Splat.Log4Net\Splat.Log4Net.csproj", "{D65C61D8-C073-4761-9BA3-C595A079C42E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,10 +51,6 @@ Global {1D8068E4-7F85-4322-BC06-3D901F392CF1}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D8068E4-7F85-4322-BC06-3D901F392CF1}.Release|Any CPU.ActiveCfg = Release|Any CPU {1D8068E4-7F85-4322-BC06-3D901F392CF1}.Release|Any CPU.Build.0 = Release|Any CPU - {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Release|Any CPU.Build.0 = Release|Any CPU {5A21B576-374D-439E-9303-02A5B0256B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5A21B576-374D-439E-9303-02A5B0256B26}.Debug|Any CPU.Build.0 = Debug|Any CPU {5A21B576-374D-439E-9303-02A5B0256B26}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -63,10 +63,18 @@ Global {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {24BCC71A-0998-4B81-9A55-BC00C2A3F8CE}.Release|Any CPU.Build.0 = Release|Any CPU - {E6EA3895-DB97-43A0-8140-EB4789796EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6EA3895-DB97-43A0-8140-EB4789796EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6EA3895-DB97-43A0-8140-EB4789796EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6EA3895-DB97-43A0-8140-EB4789796EEB}.Release|Any CPU.Build.0 = Release|Any CPU + {941DAAE2-EDCA-41A8-93FF-0C4178639A47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {941DAAE2-EDCA-41A8-93FF-0C4178639A47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {941DAAE2-EDCA-41A8-93FF-0C4178639A47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {941DAAE2-EDCA-41A8-93FF-0C4178639A47}.Release|Any CPU.Build.0 = Release|Any CPU + {E1777877-6F56-46D0-8747-4BB921ED4C8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1777877-6F56-46D0-8747-4BB921ED4C8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1777877-6F56-46D0-8747-4BB921ED4C8E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1777877-6F56-46D0-8747-4BB921ED4C8E}.Release|Any CPU.Build.0 = Release|Any CPU + {D65C61D8-C073-4761-9BA3-C595A079C42E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D65C61D8-C073-4761-9BA3-C595A079C42E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D65C61D8-C073-4761-9BA3-C595A079C42E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D65C61D8-C073-4761-9BA3-C595A079C42E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE