From 71be4574c72059a68289ef14e6cc8d7d64cc564c Mon Sep 17 00:00:00 2001 From: Kirthi Krishnamraju Date: Thu, 21 May 2015 10:33:43 -0700 Subject: [PATCH] Fix #210: Move ConfigurationBinder functionality into its own package in the Configuration repo --- Configuration.sln | 30 ++++ .../ConfigurationBinder.cs | 2 +- ...osoft.Framework.Configuration.Binder.xproj | 20 +++ .../Properties/AssemblyInfo.cs | 8 ++ .../Properties/Resources.Designer.cs | 94 +++++++++++++ .../Resources.resx | 132 ++++++++++++++++++ .../project.json | 13 ++ .../Properties/Resources.Designer.cs | 64 --------- .../Resources.resx | 12 -- .../ConfigurationBinderTests.cs | 2 +- .../ConfigurationCollectionBindingTests.cs | 2 +- ....Framework.Configuration.Binder.Test.xproj | 21 +++ .../project.json | 14 ++ 13 files changed, 335 insertions(+), 79 deletions(-) rename src/{Microsoft.Framework.Configuration => Microsoft.Framework.Configuration.Binder}/ConfigurationBinder.cs (99%) create mode 100644 src/Microsoft.Framework.Configuration.Binder/Microsoft.Framework.Configuration.Binder.xproj create mode 100644 src/Microsoft.Framework.Configuration.Binder/Properties/AssemblyInfo.cs create mode 100644 src/Microsoft.Framework.Configuration.Binder/Properties/Resources.Designer.cs create mode 100644 src/Microsoft.Framework.Configuration.Binder/Resources.resx create mode 100644 src/Microsoft.Framework.Configuration.Binder/project.json rename test/{Microsoft.Framework.Configuration.Test => Microsoft.Framework.Configuration.Binder.Test}/ConfigurationBinderTests.cs (99%) rename test/{Microsoft.Framework.Configuration.Test => Microsoft.Framework.Configuration.Binder.Test}/ConfigurationCollectionBindingTests.cs (99%) create mode 100644 test/Microsoft.Framework.Configuration.Binder.Test/Microsoft.Framework.Configuration.Binder.Test.xproj create mode 100644 test/Microsoft.Framework.Configuration.Binder.Test/project.json diff --git a/Configuration.sln b/Configuration.sln index 2899953..80315cd 100644 --- a/Configuration.sln +++ b/Configuration.sln @@ -37,6 +37,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Configu EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Configuration.EnvironmentVariables.Test", "test\Microsoft.Framework.Configuration.EnvironmentVariables.Test\Microsoft.Framework.Configuration.EnvironmentVariables.Test.xproj", "{7D0F805B-ADFF-4C47-A90C-24DD74416821}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Configuration.Binder", "src\Microsoft.Framework.Configuration.Binder\Microsoft.Framework.Configuration.Binder.xproj", "{D506FD2F-59A0-4A26-AA6D-E81998B58B34}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Configuration.Binder.Test", "test\Microsoft.Framework.Configuration.Binder.Test\Microsoft.Framework.Configuration.Binder.Test.xproj", "{AE6FFE9B-6378-4D57-AA24-7D257F18B235}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -213,6 +217,30 @@ Global {7D0F805B-ADFF-4C47-A90C-24DD74416821}.Release|Mixed Platforms.Build.0 = Release|Any CPU {7D0F805B-ADFF-4C47-A90C-24DD74416821}.Release|x86.ActiveCfg = Release|Any CPU {7D0F805B-ADFF-4C47-A90C-24DD74416821}.Release|x86.Build.0 = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|x86.ActiveCfg = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Debug|x86.Build.0 = Debug|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|Any CPU.Build.0 = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|x86.ActiveCfg = Release|Any CPU + {D506FD2F-59A0-4A26-AA6D-E81998B58B34}.Release|x86.Build.0 = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|x86.ActiveCfg = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Debug|x86.Build.0 = Debug|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|Any CPU.Build.0 = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|x86.ActiveCfg = Release|Any CPU + {AE6FFE9B-6378-4D57-AA24-7D257F18B235}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -233,5 +261,7 @@ Global {CE9C8903-AA8A-40E6-B03D-32A08A4A39AF} = {B54371FF-B920-46C8-8D55-6B19DBB43EBF} {80A8F10C-E9A6-4677-919D-FE5DB320FEDF} = {B54371FF-B920-46C8-8D55-6B19DBB43EBF} {7D0F805B-ADFF-4C47-A90C-24DD74416821} = {B54371FF-B920-46C8-8D55-6B19DBB43EBF} + {D506FD2F-59A0-4A26-AA6D-E81998B58B34} = {F141E2D0-F9B8-4ADB-A19A-7B6FF4CA19A1} + {AE6FFE9B-6378-4D57-AA24-7D257F18B235} = {B54371FF-B920-46C8-8D55-6B19DBB43EBF} EndGlobalSection EndGlobal diff --git a/src/Microsoft.Framework.Configuration/ConfigurationBinder.cs b/src/Microsoft.Framework.Configuration.Binder/ConfigurationBinder.cs similarity index 99% rename from src/Microsoft.Framework.Configuration/ConfigurationBinder.cs rename to src/Microsoft.Framework.Configuration.Binder/ConfigurationBinder.cs index 4d1bb41..84c345e 100644 --- a/src/Microsoft.Framework.Configuration/ConfigurationBinder.cs +++ b/src/Microsoft.Framework.Configuration.Binder/ConfigurationBinder.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using Microsoft.Framework.Internal; +using Microsoft.Framework.Configuration.Binder; namespace Microsoft.Framework.Configuration { diff --git a/src/Microsoft.Framework.Configuration.Binder/Microsoft.Framework.Configuration.Binder.xproj b/src/Microsoft.Framework.Configuration.Binder/Microsoft.Framework.Configuration.Binder.xproj new file mode 100644 index 0000000..b11b497 --- /dev/null +++ b/src/Microsoft.Framework.Configuration.Binder/Microsoft.Framework.Configuration.Binder.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + d506fd2f-59a0-4a26-aa6d-e81998b58b34 + Microsoft.Framework.Configuration.ConfigurationBinder + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + diff --git a/src/Microsoft.Framework.Configuration.Binder/Properties/AssemblyInfo.cs b/src/Microsoft.Framework.Configuration.Binder/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0b47734 --- /dev/null +++ b/src/Microsoft.Framework.Configuration.Binder/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.Framework.Configuration.Binder.Test")] +[assembly: AssemblyMetadata("Serviceable", "True")] diff --git a/src/Microsoft.Framework.Configuration.Binder/Properties/Resources.Designer.cs b/src/Microsoft.Framework.Configuration.Binder/Properties/Resources.Designer.cs new file mode 100644 index 0000000..653129d --- /dev/null +++ b/src/Microsoft.Framework.Configuration.Binder/Properties/Resources.Designer.cs @@ -0,0 +1,94 @@ +// +namespace Microsoft.Framework.Configuration.Binder +{ + using System.Globalization; + using System.Reflection; + using System.Resources; + + internal static class Resources + { + private static readonly ResourceManager _resourceManager + = new ResourceManager("Microsoft.Framework.Configuration.Binder.Resources", typeof(Resources).GetTypeInfo().Assembly); + + /// + /// Cannot create instance of type '{0}' because it is either abstract or an interface. + /// + internal static string Error_CannotActivateAbstractOrInterface + { + get { return GetString("Error_CannotActivateAbstractOrInterface"); } + } + + /// + /// Cannot create instance of type '{0}' because it is either abstract or an interface. + /// + internal static string FormatError_CannotActivateAbstractOrInterface(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Error_CannotActivateAbstractOrInterface"), p0); + } + + /// + /// Failed to convert '{0}' to type '{1}'. + /// + internal static string Error_FailedBinding + { + get { return GetString("Error_FailedBinding"); } + } + + /// + /// Failed to convert '{0}' to type '{1}'. + /// + internal static string FormatError_FailedBinding(object p0, object p1) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Error_FailedBinding"), p0, p1); + } + + /// + /// Failed to create instance of type '{0}'. + /// + internal static string Error_FailedToActivate + { + get { return GetString("Error_FailedToActivate"); } + } + + /// + /// Failed to create instance of type '{0}'. + /// + internal static string FormatError_FailedToActivate(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Error_FailedToActivate"), p0); + } + + /// + /// Cannot create instance of type '{0}' because it is missing a public parameterless constructor. + /// + internal static string Error_MissingParameterlessConstructor + { + get { return GetString("Error_MissingParameterlessConstructor"); } + } + + /// + /// Cannot create instance of type '{0}' because it is missing a public parameterless constructor. + /// + internal static string FormatError_MissingParameterlessConstructor(object p0) + { + return string.Format(CultureInfo.CurrentCulture, GetString("Error_MissingParameterlessConstructor"), p0); + } + + private static string GetString(string name, params string[] formatterNames) + { + var value = _resourceManager.GetString(name); + + System.Diagnostics.Debug.Assert(value != null); + + if (formatterNames != null) + { + for (var i = 0; i < formatterNames.Length; i++) + { + value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); + } + } + + return value; + } + } +} diff --git a/src/Microsoft.Framework.Configuration.Binder/Resources.resx b/src/Microsoft.Framework.Configuration.Binder/Resources.resx new file mode 100644 index 0000000..b5e04c6 --- /dev/null +++ b/src/Microsoft.Framework.Configuration.Binder/Resources.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cannot create instance of type '{0}' because it is either abstract or an interface. + + + Failed to convert '{0}' to type '{1}'. + + + Failed to create instance of type '{0}'. + + + Cannot create instance of type '{0}' because it is missing a public parameterless constructor. + + \ No newline at end of file diff --git a/src/Microsoft.Framework.Configuration.Binder/project.json b/src/Microsoft.Framework.Configuration.Binder/project.json new file mode 100644 index 0000000..2fc4702 --- /dev/null +++ b/src/Microsoft.Framework.Configuration.Binder/project.json @@ -0,0 +1,13 @@ +{ + "version": "1.0.0-*", + "description": "Binder configuration source for the Configuration package.", + "dependencies": { + "Microsoft.Framework.Configuration": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" } + }, + "frameworks": { + "net45": { }, + "dnx451": { }, + "dnxcore50": { } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.Configuration/Properties/Resources.Designer.cs b/src/Microsoft.Framework.Configuration/Properties/Resources.Designer.cs index 4010964..0518eeb 100644 --- a/src/Microsoft.Framework.Configuration/Properties/Resources.Designer.cs +++ b/src/Microsoft.Framework.Configuration/Properties/Resources.Designer.cs @@ -10,54 +10,6 @@ namespace Microsoft.Framework.Configuration private static readonly ResourceManager _resourceManager = new ResourceManager("Microsoft.Framework.Configuration.Resources", typeof(Resources).GetTypeInfo().Assembly); - /// - /// Cannot create instance of type '{0}' because it is either abstract or an interface. - /// - internal static string Error_CannotActivateAbstractOrInterface - { - get { return GetString("Error_CannotActivateAbstractOrInterface"); } - } - - /// - /// Cannot create instance of type '{0}' because it is either abstract or an interface. - /// - internal static string FormatError_CannotActivateAbstractOrInterface(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Error_CannotActivateAbstractOrInterface"), p0); - } - - /// - /// Failed to convert '{0}' to type '{1}'. - /// - internal static string Error_FailedBinding - { - get { return GetString("Error_FailedBinding"); } - } - - /// - /// Failed to convert '{0}' to type '{1}'. - /// - internal static string FormatError_FailedBinding(object p0, object p1) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Error_FailedBinding"), p0, p1); - } - - /// - /// Failed to create instance of type '{0}'. - /// - internal static string Error_FailedToActivate - { - get { return GetString("Error_FailedToActivate"); } - } - - /// - /// Failed to create instance of type '{0}'. - /// - internal static string FormatError_FailedToActivate(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Error_FailedToActivate"), p0); - } - /// /// Unable to resolve path '{0}'; construct this {1} with a non-null {2}. /// @@ -74,22 +26,6 @@ namespace Microsoft.Framework.Configuration return string.Format(CultureInfo.CurrentCulture, GetString("Error_MissingBasePath"), p0, p1, p2); } - /// - /// Cannot create instance of type '{0}' because it is missing a public parameterless constructor. - /// - internal static string Error_MissingParameterlessConstructor - { - get { return GetString("Error_MissingParameterlessConstructor"); } - } - - /// - /// Cannot create instance of type '{0}' because it is missing a public parameterless constructor. - /// - internal static string FormatError_MissingParameterlessConstructor(object p0) - { - return string.Format(CultureInfo.CurrentCulture, GetString("Error_MissingParameterlessConstructor"), p0); - } - /// /// A configuration source is not registered. Please register one before setting a value. /// diff --git a/src/Microsoft.Framework.Configuration/Resources.resx b/src/Microsoft.Framework.Configuration/Resources.resx index 0dfc382..2cc04be 100644 --- a/src/Microsoft.Framework.Configuration/Resources.resx +++ b/src/Microsoft.Framework.Configuration/Resources.resx @@ -117,21 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Cannot create instance of type '{0}' because it is either abstract or an interface. - - - Failed to convert '{0}' to type '{1}'. - - - Failed to create instance of type '{0}'. - Unable to resolve path '{0}'; construct this {1} with a non-null {2}. - - Cannot create instance of type '{0}' because it is missing a public parameterless constructor. - A configuration source is not registered. Please register one before setting a value. diff --git a/test/Microsoft.Framework.Configuration.Test/ConfigurationBinderTests.cs b/test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationBinderTests.cs similarity index 99% rename from test/Microsoft.Framework.Configuration.Test/ConfigurationBinderTests.cs rename to test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationBinderTests.cs index 329b35a..fd412d1 100644 --- a/test/Microsoft.Framework.Configuration.Test/ConfigurationBinderTests.cs +++ b/test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationBinderTests.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.Reflection; using Xunit; -namespace Microsoft.Framework.Configuration.Test +namespace Microsoft.Framework.Configuration.Binder.Test { public class ConfigurationBinderTests { diff --git a/test/Microsoft.Framework.Configuration.Test/ConfigurationCollectionBindingTests.cs b/test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationCollectionBindingTests.cs similarity index 99% rename from test/Microsoft.Framework.Configuration.Test/ConfigurationCollectionBindingTests.cs rename to test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationCollectionBindingTests.cs index bf78d9b..6c75703 100644 --- a/test/Microsoft.Framework.Configuration.Test/ConfigurationCollectionBindingTests.cs +++ b/test/Microsoft.Framework.Configuration.Binder.Test/ConfigurationCollectionBindingTests.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Generic; using Xunit; -namespace Microsoft.Framework.Configuration.Test +namespace Microsoft.Framework.Configuration.Binder.Test { public class ConfigurationCollectionBinding { diff --git a/test/Microsoft.Framework.Configuration.Binder.Test/Microsoft.Framework.Configuration.Binder.Test.xproj b/test/Microsoft.Framework.Configuration.Binder.Test/Microsoft.Framework.Configuration.Binder.Test.xproj new file mode 100644 index 0000000..28de7b5 --- /dev/null +++ b/test/Microsoft.Framework.Configuration.Binder.Test/Microsoft.Framework.Configuration.Binder.Test.xproj @@ -0,0 +1,21 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + ae6ffe9b-6378-4d57-aa24-7d257f18b235 + Microsoft.Framework.Configuration.ConfigurationBinder.Test + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Microsoft.Framework.Configuration.Binder.Test/project.json b/test/Microsoft.Framework.Configuration.Binder.Test/project.json new file mode 100644 index 0000000..4798d10 --- /dev/null +++ b/test/Microsoft.Framework.Configuration.Binder.Test/project.json @@ -0,0 +1,14 @@ +{ + "dependencies": { + "Microsoft.Framework.Configuration.Binder": "1.0.0-*", + "Microsoft.Framework.Configuration.Test.Common": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { } + }, + "commands": { + "test": "xunit.runner.aspnet" + } +}