diff --git a/Mvc.NoFun.sln b/Mvc.NoFun.sln index 33d7b08ef..22e6217da 100644 --- a/Mvc.NoFun.sln +++ b/Mvc.NoFun.sln @@ -15,8 +15,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core", "src\Microsoft.AspNet.Mvc.Core\Microsoft.AspNet.Mvc.Core.xproj", "{C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Common", "src\Microsoft.AspNet.Mvc.Common\Microsoft.AspNet.Mvc.Common.xproj", "{F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Test", "test\Microsoft.AspNet.Mvc.Razor.Test\Microsoft.AspNet.Mvc.Razor.Test.xproj", "{3F6E355E-4869-41D9-943B-D54771221A7F}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core.Test", "test\Microsoft.AspNet.Mvc.Core.Test\Microsoft.AspNet.Mvc.Core.Test.xproj", "{A8AA326E-8EE8-4F11-B750-23028E0949D7}" @@ -52,8 +50,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Xml.Te EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces", "src\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj", "{4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Common.Test", "test\Microsoft.AspNet.Mvc.Common.Test\Microsoft.AspNet.Mvc.Common.Test.xproj", "{0449D6D2-BE1B-4E29-8E1B-444420802C03}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestCommon", "test\Microsoft.AspNet.Mvc.TestCommon\Microsoft.AspNet.Mvc.TestCommon.xproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.JsonPatch.Test", "test\Microsoft.AspNet.JsonPatch.Test\Microsoft.AspNet.JsonPatch.Test.xproj", "{81C20848-E063-4E12-AC40-0B55A532C16C}" @@ -116,16 +112,6 @@ Global {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|x86.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Any CPU.Build.0 = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|x86.ActiveCfg = Release|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -290,18 +276,6 @@ Global {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.ActiveCfg = Release|Any CPU {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|x86.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|x86.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Any CPU.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.Build.0 = Release|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -441,7 +415,6 @@ Global {079EFA1F-0B0A-4853-B27B-5780D111CD85} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {314E9AD6-2FFC-4A92-A8AD-510658C64F1E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {3F6E355E-4869-41D9-943B-D54771221A7F} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {A8AA326E-8EE8-4F11-B750-23028E0949D7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {FBB2B86E-972B-4185-9FF2-62CAB5F8388F} = {DAAE4C74-D06F-4874-A166-33305D2643CE} @@ -457,7 +430,6 @@ Global {9C632DF0-DC06-410B-95AE-B5423702E84F} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {22019146-BDFA-442E-8C8E-345FB9644578} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} - {0449D6D2-BE1B-4E29-8E1B-444420802C03} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {81C20848-E063-4E12-AC40-0B55A532C16C} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {4D55F4D8-633B-462F-A5B1-FEB84BD2D534} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} diff --git a/Mvc.sln b/Mvc.sln index 484c67cdf..0f0b32519 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -15,8 +15,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core", "src\Microsoft.AspNet.Mvc.Core\Microsoft.AspNet.Mvc.Core.xproj", "{C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Common", "src\Microsoft.AspNet.Mvc.Common\Microsoft.AspNet.Mvc.Common.xproj", "{F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Test", "test\Microsoft.AspNet.Mvc.Razor.Test\Microsoft.AspNet.Mvc.Razor.Test.xproj", "{3F6E355E-4869-41D9-943B-D54771221A7F}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core.Test", "test\Microsoft.AspNet.Mvc.Core.Test\Microsoft.AspNet.Mvc.Core.Test.xproj", "{A8AA326E-8EE8-4F11-B750-23028E0949D7}" @@ -116,8 +114,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "CustomRouteWebSite", "test\ EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ResponseCacheWebSite", "test\WebSites\ResponseCacheWebSite\ResponseCacheWebSite.xproj", "{BDEEBE09-C0C4-433C-B0B8-8478C9776996}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Common.Test", "test\Microsoft.AspNet.Mvc.Common.Test\Microsoft.AspNet.Mvc.Common.Test.xproj", "{0449D6D2-BE1B-4E29-8E1B-444420802C03}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "XmlFormattersWebSite", "test\WebSites\XmlFormattersWebSite\XmlFormattersWebSite.xproj", "{C3123A70-41C4-4122-AD1C-D35DF8958DD7}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ValidationWebSite", "test\WebSites\ValidationWebSite\ValidationWebSite.xproj", "{87AB84B2-22C1-43C6-BB8A-1D327B446FB0}" @@ -216,16 +212,6 @@ Global {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF}.Release|x86.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Any CPU.Build.0 = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD}.Release|x86.ActiveCfg = Release|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {3F6E355E-4869-41D9-943B-D54771221A7F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -708,18 +694,6 @@ Global {BDEEBE09-C0C4-433C-B0B8-8478C9776996}.Release|Mixed Platforms.Build.0 = Release|Any CPU {BDEEBE09-C0C4-433C-B0B8-8478C9776996}.Release|x86.ActiveCfg = Release|Any CPU {BDEEBE09-C0C4-433C-B0B8-8478C9776996}.Release|x86.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|x86.ActiveCfg = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Debug|x86.Build.0 = Debug|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Any CPU.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.ActiveCfg = Release|Any CPU - {0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.Build.0 = Release|Any CPU {C3123A70-41C4-4122-AD1C-D35DF8958DD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C3123A70-41C4-4122-AD1C-D35DF8958DD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {C3123A70-41C4-4122-AD1C-D35DF8958DD7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -1076,7 +1050,6 @@ Global {079EFA1F-0B0A-4853-B27B-5780D111CD85} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {314E9AD6-2FFC-4A92-A8AD-510658C64F1E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {C48DA9D7-ACB5-4408-AA79-27ECB60A67EF} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} - {F3DF6D0B-16FE-4402-B92C-7243A75CF1FD} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {3F6E355E-4869-41D9-943B-D54771221A7F} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {A8AA326E-8EE8-4F11-B750-23028E0949D7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {FBB2B86E-972B-4185-9FF2-62CAB5F8388F} = {DAAE4C74-D06F-4874-A166-33305D2643CE} @@ -1124,7 +1097,6 @@ Global {AF210F69-9D31-43AF-AC3A-CD366E252218} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {364EC3C6-C9DB-45E0-A0F2-1EE61E4B429B} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {BDEEBE09-C0C4-433C-B0B8-8478C9776996} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} - {0449D6D2-BE1B-4E29-8E1B-444420802C03} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {C3123A70-41C4-4122-AD1C-D35DF8958DD7} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {87AB84B2-22C1-43C6-BB8A-1D327B446FB0} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {22019146-BDFA-442E-8C8E-345FB9644578} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelMetadata.cs b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelMetadata.cs index 43c21af51..8e77c345f 100644 --- a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelMetadata.cs +++ b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelMetadata.cs @@ -317,7 +317,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// public bool IsNullableValueType { - get { return TypeHelper.IsNullableValueType(ModelType); } + get + { + return Nullable.GetUnderlyingType(ModelType) != null; + } } /// diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/project.json b/src/Microsoft.AspNet.Mvc.Abstractions/project.json index d65d1c7e4..3764d65c6 100644 --- a/src/Microsoft.AspNet.Mvc.Abstractions/project.json +++ b/src/Microsoft.AspNet.Mvc.Abstractions/project.json @@ -5,7 +5,6 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Routing": "1.0.0-*", "Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, diff --git a/src/Microsoft.AspNet.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs index bc72e6820..1496cfe29 100644 --- a/src/Microsoft.AspNet.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs @@ -358,7 +358,7 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer } // Unwrap the type if it's a Task. The Task (non-generic) case was already handled. - var unwrappedType = TypeHelper.GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; + var unwrappedType = GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; // If the method is declared to return IActionResult or a derived class, that information // isn't valuable to the formatter. @@ -372,6 +372,13 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer } } + private static Type GetTaskInnerTypeOrNull(Type type) + { + var genericType = ClosedGenericMatcher.ExtractGenericInterface(type, typeof(Task<>)); + + return genericType?.GenericTypeArguments[0]; + } + private Type GetRuntimeReturnType(Type declaredReturnType, IApiResponseMetadataProvider[] metadataAttributes) { // Walk through all of the filter attributes and allow them to set the type. This will execute them @@ -550,7 +557,7 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer // public class OrderDTO // { // public int AccountId { get; set; } - // + // // [FromBody] // public Order { get; set; } // } diff --git a/src/Microsoft.AspNet.Mvc.ApiExplorer/project.json b/src/Microsoft.AspNet.Mvc.ApiExplorer/project.json index 4834d6be7..8eb7bb01b 100644 --- a/src/Microsoft.AspNet.Mvc.ApiExplorer/project.json +++ b/src/Microsoft.AspNet.Mvc.ApiExplorer/project.json @@ -5,9 +5,9 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Mvc.Core": "6.0.0-*", "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" } }, "frameworks": { diff --git a/src/Microsoft.AspNet.Mvc.Common/Encodings.cs b/src/Microsoft.AspNet.Mvc.Common/Encodings.cs deleted file mode 100644 index 181917d53..000000000 --- a/src/Microsoft.AspNet.Mvc.Common/Encodings.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.Text; - -namespace Microsoft.AspNet.Mvc -{ - internal static class Encodings - { - /// - /// Returns UTF8 Encoding without BOM and throws on invalid bytes. - /// - public static readonly Encoding UTF8EncodingWithoutBOM - = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); - - /// - /// Returns UTF16 Encoding which uses littleEndian byte order with BOM and throws on invalid bytes. - /// - public static readonly Encoding UTF16EncodingLittleEndian = new UnicodeEncoding(bigEndian: false, - byteOrderMark: true, - throwOnInvalidBytes: true); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Common/Microsoft.AspNet.Mvc.Common.xproj b/src/Microsoft.AspNet.Mvc.Common/Microsoft.AspNet.Mvc.Common.xproj deleted file mode 100644 index 7193b980d..000000000 --- a/src/Microsoft.AspNet.Mvc.Common/Microsoft.AspNet.Mvc.Common.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f3df6d0b-16fe-4402-b92c-7243a75cf1fd - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Common/TaskHelper.cs b/src/Microsoft.AspNet.Mvc.Common/TaskHelper.cs deleted file mode 100644 index 0aa5e1316..000000000 --- a/src/Microsoft.AspNet.Mvc.Common/TaskHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -// 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.Threading.Tasks; - -namespace Microsoft.AspNet.Mvc -{ - /// - /// Utility methods for dealing with . - /// - internal static class TaskHelper - { - /// - /// Waits for the task to complete and throws the first faulting exception if the task is faulted. - /// It preserves the original stack trace when throwing the exception. - /// - /// - /// Invoking this method is equivalent to calling Wait() on the if it is not completed. - /// - public static void WaitAndThrowIfFaulted(Task task) - { - task.GetAwaiter().GetResult(); - } - - /// - /// Waits for the task to complete and throws the first faulting exception if the task is faulted. - /// It preserves the original stack trace when throwing the exception. - /// - /// - /// Invoking this method is equivalent to calling on the - /// if it is not completed. - /// - public static TVal WaitAndThrowIfFaulted(Task task) - { - return task.GetAwaiter().GetResult(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Common/TypeHelper.cs b/src/Microsoft.AspNet.Mvc.Common/TypeHelper.cs deleted file mode 100644 index 194412196..000000000 --- a/src/Microsoft.AspNet.Mvc.Common/TypeHelper.cs +++ /dev/null @@ -1,95 +0,0 @@ -// 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; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.Framework.Internal; - -namespace Microsoft.AspNet.Mvc -{ - internal static class TypeHelper - { - private static readonly Type TaskGenericType = typeof(Task<>); - - public static Type GetTaskInnerTypeOrNull([NotNull] Type type) - { - var typeInfo = type.GetTypeInfo(); - if (typeInfo.IsGenericType && !typeInfo.IsGenericTypeDefinition) - { - var genericTypeDefinition = typeInfo.GetGenericTypeDefinition(); - var genericArguments = typeInfo.GenericTypeArguments; - if (genericArguments.Length == 1 && TaskGenericType == genericTypeDefinition) - { - // Only Return if there is a single argument. - return genericArguments[0]; - } - } - - return null; - } - - /// - /// Given an object, adds each instance property with a public get method as a key and its - /// associated value to a dictionary. - /// - /// If the object is already an instance, then a copy - /// is returned. - /// - /// - /// The implementation of PropertyHelper will cache the property accessors per-type. This is - /// faster when the the same type is used multiple times with ObjectToDictionary. - /// - public static IDictionary ObjectToDictionary(object value) - { - var dictionary = value as IDictionary; - if (dictionary != null) - { - return new Dictionary(dictionary, StringComparer.OrdinalIgnoreCase); - } - - dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); - - if (value != null) - { - foreach (var helper in PropertyHelper.GetProperties(value)) - { - dictionary[helper.Name] = helper.GetValue(value); - } - } - - return dictionary; - } - - public static bool IsSimpleType(Type type) - { - return type.GetTypeInfo().IsPrimitive || - type.Equals(typeof(decimal)) || - type.Equals(typeof(string)) || - type.Equals(typeof(DateTime)) || - type.Equals(typeof(Guid)) || - type.Equals(typeof(DateTimeOffset)) || - type.Equals(typeof(TimeSpan)) || - type.Equals(typeof(Uri)); - } - - public static bool IsCompatibleWith([NotNull] Type type, object value) - { - return (value == null && AllowsNullValue(type)) || - (value != null && type.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo())); - } - - public static bool IsNullableValueType([NotNull] Type type) - { - return Nullable.GetUnderlyingType(type) != null; - } - - public static bool AllowsNullValue([NotNull] Type type) - { - return !type.GetTypeInfo().IsValueType || IsNullableValueType(type); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Common/project.json b/src/Microsoft.AspNet.Mvc.Common/project.json deleted file mode 100644 index 7606e5535..000000000 --- a/src/Microsoft.AspNet.Mvc.Common/project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "6.0.0-*", - "shared": "*.cs", - "dependencies": { - }, - "frameworks": { - "net45": { }, - "dnx451": { }, - "dnxcore50": { - "dependencies": { - "System.Runtime": "4.0.20-beta-*" - } - } - } -} diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs index 64dfdbab7..9e306ef07 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionExecutor.cs @@ -9,6 +9,7 @@ using System.Reflection; using System.Runtime.ExceptionServices; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.Core; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc { @@ -79,7 +80,7 @@ namespace Microsoft.AspNet.Mvc return CastToObject(resultAsTask); } - var taskValueType = TypeHelper.GetTaskInnerTypeOrNull(returnType); + var taskValueType = GetTaskInnerTypeOrNull(returnType); if (taskValueType != null) { // for: public Task Action() @@ -154,7 +155,7 @@ namespace Microsoft.AspNet.Mvc // This most likely indicates that the developer forgot to call Unwrap() somewhere. if (actualTypeReturned != typeof(Task)) { - var innerTaskType = TypeHelper.GetTaskInnerTypeOrNull(actualTypeReturned); + var innerTaskType = GetTaskInnerTypeOrNull(actualTypeReturned); if (innerTaskType != null && typeof(Task).IsAssignableFrom(innerTaskType)) { throw new InvalidOperationException( @@ -182,5 +183,12 @@ namespace Microsoft.AspNet.Mvc { return (object)await task; } + + private static Type GetTaskInnerTypeOrNull(Type type) + { + var genericType = ClosedGenericMatcher.ExtractGenericInterface(type, typeof(Task<>)); + + return genericType?.GenericTypeArguments[0]; + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs index 274060f93..e70133c1f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionInvoker.cs @@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.Core } // Unwrap potential Task types. - var actualReturnType = TypeHelper.GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; + var actualReturnType = GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; if (actionReturnValue == null && typeof(IActionResult).GetTypeInfo().IsAssignableFrom(actualReturnType.GetTypeInfo())) { @@ -125,5 +125,12 @@ namespace Microsoft.AspNet.Mvc.Core DeclaredType = actualReturnType }; } + + private static Type GetTaskInnerTypeOrNull(Type type) + { + var genericType = ClosedGenericMatcher.ExtractGenericInterface(type, typeof(Task<>)); + + return genericType?.GenericTypeArguments[0]; + } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerActionArgumentBinder.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerActionArgumentBinder.cs index 896f10d83..daeab334e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerActionArgumentBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerActionArgumentBinder.cs @@ -128,7 +128,7 @@ namespace Microsoft.AspNet.Mvc if (propertyHelper.Property.CanWrite && propertyHelper.Property.SetMethod?.IsPublic == true) { // Handle settable property. Do not set the property if the type is a non-nullable type. - if (source != null || TypeHelper.AllowsNullValue(propertyType)) + if (source != null || AllowsNullValue(propertyType)) { propertyHelper.SetValue(controller, source); } @@ -218,5 +218,10 @@ namespace Microsoft.AspNet.Mvc ValueProvider = bindingContext.ValueProvider, }; } + + private static bool AllowsNullValue([NotNull] Type type) + { + return !type.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(type) != null; + } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs b/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs index 368cb595c..4e09ebcef 100644 --- a/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/InputFormatter.cs @@ -17,6 +17,18 @@ namespace Microsoft.AspNet.Mvc /// public abstract class InputFormatter : IInputFormatter { + /// + /// Returns UTF8 Encoding without BOM and throws on invalid bytes. + /// + protected static readonly Encoding UTF8EncodingWithoutBOM + = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); + + /// + /// Returns UTF16 Encoding which uses littleEndian byte order with BOM and throws on invalid bytes. + /// + protected static readonly Encoding UTF16EncodingLittleEndian + = new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true); + /// /// Gets the mutable collection of character encodings supported by /// this . The encodings are diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Metadata/DefaultModelMetadata.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Metadata/DefaultModelMetadata.cs index 24beb39bb..b5c3d6886 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Metadata/DefaultModelMetadata.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Metadata/DefaultModelMetadata.cs @@ -7,9 +7,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; -#if DNXCORE50 using System.Reflection; -#endif using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata @@ -403,7 +401,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata } else { - _isRequired = !TypeHelper.AllowsNullValue(ModelType); + _isRequired = !AllowsNullValue(ModelType); } } @@ -521,5 +519,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata return _details.PropertySetter; } } + + private static bool AllowsNullValue([NotNull] Type type) + { + return !type.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(type) != null; + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/TypeMatchModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/TypeMatchModelBinder.cs index 4d034786e..b7b6f45ce 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/TypeMatchModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/TypeMatchModelBinder.cs @@ -1,7 +1,10 @@ // 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; +using System.Reflection; using System.Threading.Tasks; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.Mvc.ModelBinding { @@ -41,12 +44,24 @@ namespace Microsoft.AspNet.Mvc.ModelBinding return null; // the value doesn't exist } - if (!TypeHelper.IsCompatibleWith(context.ModelType, valueProviderResult.RawValue)) + if (!IsCompatibleWith(context.ModelType, valueProviderResult.RawValue)) { return null; // value is of incompatible type } return valueProviderResult; } + + private static bool IsCompatibleWith([NotNull] Type type, object value) + { + if (value == null) + { + return !type.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(type) != null; + } + else + { + return type.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()); + } + } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/SimpleTypesExcludeFilter.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/SimpleTypesExcludeFilter.cs index 0561ab761..072f1120d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/SimpleTypesExcludeFilter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/SimpleTypesExcludeFilter.cs @@ -8,12 +8,12 @@ using System.Reflection; namespace Microsoft.AspNet.Mvc.ModelBinding.Validation { /// - /// Identifies the simple types that the default model binding validation will exclude. + /// Identifies the simple types that the default model binding validation will exclude. /// public class SimpleTypesExcludeFilter : IExcludeTypeValidationFilter { /// - /// Returns true if the given type will be excluded from the default model validation. + /// Returns true if the given type will be excluded from the default model validation. /// public bool IsTypeExcluded(Type type) { @@ -46,7 +46,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation /// protected virtual bool IsSimpleType(Type type) { - return TypeHelper.IsSimpleType(type); + return type.GetTypeInfo().IsPrimitive || + type.Equals(typeof(decimal)) || + type.Equals(typeof(string)) || + type.Equals(typeof(DateTime)) || + type.Equals(typeof(Guid)) || + type.Equals(typeof(DateTimeOffset)) || + type.Equals(typeof(TimeSpan)) || + type.Equals(typeof(Uri)); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/SessionStateTempDataProvider.cs b/src/Microsoft.AspNet.Mvc.Core/SessionStateTempDataProvider.cs index 022131e12..05e96716a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/SessionStateTempDataProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/SessionStateTempDataProvider.cs @@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Mvc } actualType = actualType ?? itemType; - if (!TypeHelper.IsSimpleType(actualType)) + if (!IsSimpleType(actualType)) { var underlyingType = Nullable.GetUnderlyingType(actualType) ?? actualType; var message = Resources.FormatTempData_CannotSerializeToSession( @@ -248,5 +248,17 @@ namespace Microsoft.AspNet.Mvc } return convertedDictionary; } + + private static bool IsSimpleType(Type type) + { + return type.GetTypeInfo().IsPrimitive || + type.Equals(typeof(decimal)) || + type.Equals(typeof(string)) || + type.Equals(typeof(DateTime)) || + type.Equals(typeof(Guid)) || + type.Equals(typeof(DateTimeOffset)) || + type.Equals(typeof(TimeSpan)) || + type.Equals(typeof(Uri)); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs index e4b6dc108..a4640da36 100644 --- a/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Core/StringOutputFormatter.cs @@ -1,6 +1,7 @@ // 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.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.Net.Http.Headers; @@ -14,8 +15,8 @@ namespace Microsoft.AspNet.Mvc { public StringOutputFormatter() { - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(Encoding.UTF8); + SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/plain")); } diff --git a/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs index 76882f5e4..5f787503f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/UrlHelper.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc /// public virtual string Action(UrlActionContext actionContext) { - var valuesDictionary = TypeHelper.ObjectToDictionary(actionContext.Values); + var valuesDictionary = PropertyHelper.ObjectToDictionary(actionContext.Values); if (actionContext.Action != null) { @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Mvc /// public virtual string RouteUrl(UrlRouteContext routeContext) { - var valuesDictionary = TypeHelper.ObjectToDictionary(routeContext.Values); + var valuesDictionary = PropertyHelper.ObjectToDictionary(routeContext.Values); var path = GeneratePathFromRoute(routeContext.RouteName, valuesDictionary); if (path == null) diff --git a/src/Microsoft.AspNet.Mvc.Core/project.json b/src/Microsoft.AspNet.Mvc.Core/project.json index 2594448f3..78e579aa8 100644 --- a/src/Microsoft.AspNet.Mvc.Core/project.json +++ b/src/Microsoft.AspNet.Mvc.Core/project.json @@ -8,7 +8,6 @@ "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*", "Microsoft.AspNet.Http": "1.0.0-*", "Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*", - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.WebUtilities": "1.0.0-*", "Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.Logging.Abstractions": "1.0.0-*", diff --git a/src/Microsoft.AspNet.Mvc.Extensions/ContentResult.cs b/src/Microsoft.AspNet.Mvc.Extensions/ContentResult.cs index bc4bc9e45..85d346bb1 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/ContentResult.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/ContentResult.cs @@ -1,8 +1,6 @@ // 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; -using System.IO; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -15,7 +13,7 @@ namespace Microsoft.AspNet.Mvc { private readonly MediaTypeHeaderValue DefaultContentType = new MediaTypeHeaderValue("text/plain") { - Encoding = Encodings.UTF8EncodingWithoutBOM + Encoding = Encoding.UTF8 }; /// @@ -42,7 +40,7 @@ namespace Microsoft.AspNet.Mvc if (contentTypeHeader == null) { contentTypeHeader = DefaultContentType; - encoding = Encodings.UTF8EncodingWithoutBOM; + encoding = Encoding.UTF8; } else { @@ -51,9 +49,9 @@ namespace Microsoft.AspNet.Mvc // 1. Do not modify the user supplied content type // 2. Parse here to handle parameters apart from charset contentTypeHeader = MediaTypeHeaderValue.Parse(contentTypeHeader.ToString()); - contentTypeHeader.Encoding = Encodings.UTF8EncodingWithoutBOM; + contentTypeHeader.Encoding = Encoding.UTF8; - encoding = Encodings.UTF8EncodingWithoutBOM; + encoding = Encoding.UTF8; } else { diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Controller.cs b/src/Microsoft.AspNet.Mvc.Extensions/Controller.cs index ae078f08f..99a6b3951 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Controller.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Controller.cs @@ -505,7 +505,7 @@ namespace Microsoft.AspNet.Mvc public virtual RedirectToActionResult RedirectToAction(string actionName, string controllerName, object routeValues) { - return new RedirectToActionResult(actionName, controllerName, TypeHelper.ObjectToDictionary(routeValues)) + return new RedirectToActionResult(actionName, controllerName, PropertyHelper.ObjectToDictionary(routeValues)) { UrlHelper = Url, }; @@ -565,7 +565,7 @@ namespace Microsoft.AspNet.Mvc return new RedirectToActionResult( actionName, controllerName, - TypeHelper.ObjectToDictionary(routeValues), + PropertyHelper.ObjectToDictionary(routeValues), permanent: true) { UrlHelper = Url, diff --git a/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtActionResult.cs b/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtActionResult.cs index b6256f63b..e006b1e39 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtActionResult.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtActionResult.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc { ActionName = actionName; ControllerName = controllerName; - RouteValues = TypeHelper.ObjectToDictionary(routeValues); + RouteValues = PropertyHelper.ObjectToDictionary(routeValues); StatusCode = StatusCodes.Status201Created; } diff --git a/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtRouteResult.cs b/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtRouteResult.cs index 78efdb9f3..5f7f4258d 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtRouteResult.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/CreatedAtRouteResult.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc : base(value) { RouteName = routeName; - RouteValues = TypeHelper.ObjectToDictionary(routeValues); + RouteValues = PropertyHelper.ObjectToDictionary(routeValues); StatusCode = StatusCodes.Status201Created; } diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonInputFormatter.cs index 7ba72c062..60d2d5722 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonInputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonInputFormatter.cs @@ -25,8 +25,8 @@ namespace Microsoft.AspNet.Mvc { _serializerSettings = serializerSettings; - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(UTF8EncodingWithoutBOM); + SupportedEncodings.Add(UTF16EncodingLittleEndian); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/json")); diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonOutputFormatter.cs index 790fb2d76..5c6638874 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Formatters/JsonOutputFormatter.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.Internal; using Microsoft.Framework.Internal; @@ -26,8 +27,8 @@ namespace Microsoft.AspNet.Mvc { _serializerSettings = serializerSettings; - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(Encoding.UTF8); + SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/json")); } diff --git a/src/Microsoft.AspNet.Mvc.Extensions/RedirectToRouteResult.cs b/src/Microsoft.AspNet.Mvc.Extensions/RedirectToRouteResult.cs index 3f189f157..ee0f0c0ea 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/RedirectToRouteResult.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/RedirectToRouteResult.cs @@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc bool permanent) { RouteName = routeName; - RouteValues = TypeHelper.ObjectToDictionary(routeValues); + RouteValues = PropertyHelper.ObjectToDictionary(routeValues); Permanent = permanent; } diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Html/HtmlHelper.cs index cd4590ac4..00624c36e 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Html/HtmlHelper.cs @@ -148,7 +148,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The created dictionary of property names and property values. public static IDictionary ObjectToDictionary(object value) { - return TypeHelper.ObjectToDictionary(value); + return PropertyHelper.ObjectToDictionary(value); } /// diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/HtmlHelperPartialExtensions.cs b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/HtmlHelperPartialExtensions.cs index 4b2ca6895..ae3738c24 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/HtmlHelperPartialExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/HtmlHelperPartialExtensions.cs @@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.Rendering ViewDataDictionary viewData) { var result = htmlHelper.PartialAsync(partialViewName, model, viewData); - return TaskHelper.WaitAndThrowIfFaulted(result); + return result.GetAwaiter().GetResult(); } /// diff --git a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Internal/TemplateRenderer.cs b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Internal/TemplateRenderer.cs index eaaf7bb0a..cc1b08876 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Internal/TemplateRenderer.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/Rendering/Internal/TemplateRenderer.cs @@ -110,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Internal { var viewContext = new ViewContext(_viewContext, viewEngineResult.View, _viewData, writer); var renderTask = viewEngineResult.View.RenderAsync(viewContext); - TaskHelper.WaitAndThrowIfFaulted(renderTask); + renderTask.GetAwaiter().GetResult(); return writer.ToString(); } } diff --git a/src/Microsoft.AspNet.Mvc.Extensions/ViewComponents/ViewViewComponentResult.cs b/src/Microsoft.AspNet.Mvc.Extensions/ViewComponents/ViewViewComponentResult.cs index c7186b0bd..5a43927eb 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/ViewComponents/ViewViewComponentResult.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/ViewComponents/ViewViewComponentResult.cs @@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Mvc public void Execute([NotNull] ViewComponentContext context) { var task = ExecuteAsync(context); - TaskHelper.WaitAndThrowIfFaulted(task); + task.GetAwaiter().GetResult(); } /// diff --git a/src/Microsoft.AspNet.Mvc.Extensions/ViewDataDictionary.cs b/src/Microsoft.AspNet.Mvc.Extensions/ViewDataDictionary.cs index a9ddda06c..7a2158a4b 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/ViewDataDictionary.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/ViewDataDictionary.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Reflection; using Microsoft.AspNet.Mvc.Extensions; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Rendering.Expressions; @@ -404,7 +405,7 @@ namespace Microsoft.AspNet.Mvc { // IsCompatibleObject verifies if the value is either an instance of _declaredModelType or (if value is // null) that _declaredModelType is a nullable type. - var castWillSucceed = TypeHelper.IsCompatibleWith(_declaredModelType, value); + var castWillSucceed = IsCompatibleWith(_declaredModelType, value); if (!castWillSucceed) { string message; @@ -426,6 +427,18 @@ namespace Microsoft.AspNet.Mvc return (value == null) ? _declaredModelType : value.GetType(); } + private static bool IsCompatibleWith([NotNull] Type type, object value) + { + if (value == null) + { + return !type.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(type) != null; + } + else + { + return type.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()); + } + } + #region IDictionary methods public void Add([NotNull] string key, object value) { diff --git a/src/Microsoft.AspNet.Mvc.Extensions/ViewExecutor.cs b/src/Microsoft.AspNet.Mvc.Extensions/ViewExecutor.cs index 966819c2a..0d4986259 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/ViewExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.Extensions/ViewExecutor.cs @@ -1,14 +1,11 @@ // 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; -using System.IO; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.Framework.Internal; using Microsoft.Net.Http.Headers; -using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Mvc { @@ -20,7 +17,7 @@ namespace Microsoft.AspNet.Mvc private const int BufferSize = 1024; private static readonly MediaTypeHeaderValue DefaultContentType = new MediaTypeHeaderValue("text/html") { - Encoding = Encodings.UTF8EncodingWithoutBOM + Encoding = Encoding.UTF8 }; /// @@ -45,7 +42,7 @@ namespace Microsoft.AspNet.Mvc if (contentTypeHeader == null) { contentTypeHeader = DefaultContentType; - encoding = Encodings.UTF8EncodingWithoutBOM; + encoding = Encoding.UTF8; } else { @@ -54,9 +51,9 @@ namespace Microsoft.AspNet.Mvc // 1. Do not modify the user supplied content type // 2. Parse here to handle parameters apart from charset contentTypeHeader = MediaTypeHeaderValue.Parse(contentTypeHeader.ToString()); - contentTypeHeader.Encoding = Encodings.UTF8EncodingWithoutBOM; + contentTypeHeader.Encoding = Encoding.UTF8; - encoding = Encodings.UTF8EncodingWithoutBOM; + encoding = Encoding.UTF8; } else { diff --git a/src/Microsoft.AspNet.Mvc.Extensions/project.json b/src/Microsoft.AspNet.Mvc.Extensions/project.json index a18f0c225..26333387e 100644 --- a/src/Microsoft.AspNet.Mvc.Extensions/project.json +++ b/src/Microsoft.AspNet.Mvc.Extensions/project.json @@ -13,7 +13,6 @@ "Microsoft.AspNet.Diagnostics.Abstractions": "1.0.0-*", "Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*", "Microsoft.AspNet.JsonPatch": "1.0.0-*", - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Mvc.Core": "6.0.0-*", "Microsoft.Framework.BufferEntryCollection.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" }, diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs index 5d4f46e78..b669c116f 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs @@ -709,7 +709,7 @@ namespace Microsoft.AspNet.Mvc.Razor EnsureMethodCanBeInvoked(nameof(RenderSection)); var task = RenderSectionAsyncCore(name, required); - return TaskHelper.WaitAndThrowIfFaulted(task); + return task.GetAwaiter().GetResult(); } /// diff --git a/src/Microsoft.AspNet.Mvc.Razor/project.json b/src/Microsoft.AspNet.Mvc.Razor/project.json index bb453fe59..d19b84028 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/project.json +++ b/src/Microsoft.AspNet.Mvc.Razor/project.json @@ -5,7 +5,6 @@ "warningsAsErrors": false }, "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Mvc.Extensions": "6.0.0-*", "Microsoft.AspNet.Mvc.Razor.Host": "6.0.0-*", "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces": "1.0.0-*", diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Conventions/WebApiParameterConventionsApplicationModelConvention.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Conventions/WebApiParameterConventionsApplicationModelConvention.cs index d8131722d..aba7bbb12 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Conventions/WebApiParameterConventionsApplicationModelConvention.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/Conventions/WebApiParameterConventionsApplicationModelConvention.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Reflection; using System.Web.Http; using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.AspNet.Mvc.ModelBinding; @@ -65,8 +66,20 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim private static bool CanConvertFromString(Type destinationType) { destinationType = Nullable.GetUnderlyingType(destinationType) ?? destinationType; - return TypeHelper.IsSimpleType(destinationType) || + return IsSimpleType(destinationType) || TypeDescriptor.GetConverter(destinationType).CanConvertFrom(typeof(string)); } + + private static bool IsSimpleType(Type type) + { + return type.GetTypeInfo().IsPrimitive || + type.Equals(typeof(decimal)) || + type.Equals(typeof(string)) || + type.Equals(typeof(DateTime)) || + type.Equals(typeof(Guid)) || + type.Equals(typeof(DateTimeOffset)) || + type.Equals(typeof(TimeSpan)) || + type.Equals(typeof(Uri)); + } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs index 8038424cc..520b709a4 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Net.Http.Formatting; +using System.Reflection; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Routing; @@ -159,10 +160,22 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim private static bool CanConvertFromString(Type destinationType) { destinationType = Nullable.GetUnderlyingType(destinationType) ?? destinationType; - return TypeHelper.IsSimpleType(destinationType) || + return IsSimpleType(destinationType) || TypeDescriptor.GetConverter(destinationType).CanConvertFrom(typeof(string)); } + private static bool IsSimpleType(Type type) + { + return type.GetTypeInfo().IsPrimitive || + type.Equals(typeof(decimal)) || + type.Equals(typeof(string)) || + type.Equals(typeof(DateTime)) || + type.Equals(typeof(Guid)) || + type.Equals(typeof(DateTimeOffset)) || + type.Equals(typeof(TimeSpan)) || + type.Equals(typeof(Uri)); + } + private class OverloadedParameter { public ParameterDescriptor ParameterDescriptor { get; set; } diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/project.json b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/project.json index a16a28029..196abc874 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/project.json +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/project.json @@ -5,7 +5,6 @@ "warningsAsErrors": false }, "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "type": "build", "version": "6.0.0-*" }, "Microsoft.AspNet.Mvc.Extensions": "6.0.0-*", "Microsoft.AspNet.WebApi.Client": "5.2.2", "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }, diff --git a/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerInputFormatter.cs index 2e23668db..d24496f4a 100644 --- a/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerInputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerInputFormatter.cs @@ -24,14 +24,14 @@ namespace Microsoft.AspNet.Mvc.Xml private DataContractSerializerSettings _serializerSettings; private ConcurrentDictionary _serializerCache = new ConcurrentDictionary(); private readonly XmlDictionaryReaderQuotas _readerQuotas = FormattingUtilities.GetDefaultXmlReaderQuotas(); - + /// /// Initializes a new instance of DataContractSerializerInputFormatter /// public XmlDataContractSerializerInputFormatter() { - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(UTF8EncodingWithoutBOM); + SupportedEncodings.Add(UTF16EncodingLittleEndian); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/xml")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/xml")); @@ -67,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.Xml } /// - /// Gets or sets the used to configure the + /// Gets or sets the used to configure the /// . /// public DataContractSerializerSettings SerializerSettings diff --git a/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerOutputFormatter.cs index 1755d630a..a8f3c699e 100644 --- a/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Xml/XmlDataContractSerializerOutputFormatter.cs @@ -6,9 +6,9 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Runtime.Serialization; +using System.Text; using System.Threading.Tasks; using System.Xml; -using Microsoft.AspNet.Mvc.Internal; using Microsoft.Framework.Internal; using Microsoft.Net.Http.Headers; @@ -38,8 +38,8 @@ namespace Microsoft.AspNet.Mvc.Xml /// The settings to be used by the . public XmlDataContractSerializerOutputFormatter([NotNull] XmlWriterSettings writerSettings) { - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(Encoding.UTF8); + SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/xml")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/xml")); diff --git a/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerInputFormatter.cs b/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerInputFormatter.cs index 6d958f60f..a175845b6 100644 --- a/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerInputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerInputFormatter.cs @@ -29,8 +29,8 @@ namespace Microsoft.AspNet.Mvc.Xml /// public XmlSerializerInputFormatter() { - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(UTF8EncodingWithoutBOM); + SupportedEncodings.Add(UTF16EncodingLittleEndian); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/xml")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/xml")); diff --git a/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerOutputFormatter.cs b/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerOutputFormatter.cs index 3d57a3c47..d76e70173 100644 --- a/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerOutputFormatter.cs +++ b/src/Microsoft.AspNet.Mvc.Xml/XmlSerializerOutputFormatter.cs @@ -5,10 +5,10 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; +using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; -using Microsoft.AspNet.Mvc.Internal; using Microsoft.Framework.Internal; using Microsoft.Net.Http.Headers; @@ -37,8 +37,8 @@ namespace Microsoft.AspNet.Mvc.Xml /// The settings to be used by the . public XmlSerializerOutputFormatter([NotNull] XmlWriterSettings writerSettings) { - SupportedEncodings.Add(Encodings.UTF8EncodingWithoutBOM); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(Encoding.UTF8); + SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/xml")); SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("text/xml")); diff --git a/src/Microsoft.AspNet.Mvc.Xml/project.json b/src/Microsoft.AspNet.Mvc.Xml/project.json index fe20f7002..84e744455 100644 --- a/src/Microsoft.AspNet.Mvc.Xml/project.json +++ b/src/Microsoft.AspNet.Mvc.Xml/project.json @@ -5,7 +5,6 @@ "warningsAsErrors": true }, "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Mvc.Extensions": "6.0.0-*", "Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, diff --git a/test/Microsoft.AspNet.Mvc.Common.Test/Microsoft.AspNet.Mvc.Common.Test.xproj b/test/Microsoft.AspNet.Mvc.Common.Test/Microsoft.AspNet.Mvc.Common.Test.xproj deleted file mode 100644 index 1af7a206a..000000000 --- a/test/Microsoft.AspNet.Mvc.Common.Test/Microsoft.AspNet.Mvc.Common.Test.xproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 0449d6d2-be1b-4e29-8e1b-444420802c03 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Common.Test/TaskHelperTest.cs b/test/Microsoft.AspNet.Mvc.Common.Test/TaskHelperTest.cs deleted file mode 100644 index 517f723b3..000000000 --- a/test/Microsoft.AspNet.Mvc.Common.Test/TaskHelperTest.cs +++ /dev/null @@ -1,58 +0,0 @@ -// 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; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNet.Mvc -{ - public class TaskHelperTest - { - [Fact] - public void WaitAndThrowIfFaulted_DoesNotThrowIfTaskIsNotFaulted() - { - // Arrange - var task = Task.FromResult(0); - - // Act and Assert (does not throw) - TaskHelper.WaitAndThrowIfFaulted(task); - } - - [Fact] - public void WaitAndThrowIfFaulted_ThrowsIfTaskIsFaulted() - { - // Arrange - var message = "Exception message"; - var task = CreatingFailingTask(message); - - // Act and Assert - var ex = Assert.Throws(() => TaskHelper.WaitAndThrowIfFaulted(task)); - Assert.Equal(message, ex.Message); - } - - [Fact] - public void WaitAndThrowIfFaulted_ThrowsFirstExceptionWhenAggregateTaskFails() - { - // Arrange - var message = "Exception message"; - var task = Task.Run(async () => - { - await Task.WhenAll(CreatingFailingTask(message), - CreatingFailingTask("different message")); - }); - - // Act and Assert - var ex = Assert.Throws(() => TaskHelper.WaitAndThrowIfFaulted(task)); - Assert.Equal(message, ex.Message); - } - - private static Task CreatingFailingTask(string message) - { - return Task.Run(() => - { - throw new Exception(message); - }); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Common.Test/TypeHelperTest.cs b/test/Microsoft.AspNet.Mvc.Common.Test/TypeHelperTest.cs deleted file mode 100644 index 75e5b2606..000000000 --- a/test/Microsoft.AspNet.Mvc.Common.Test/TypeHelperTest.cs +++ /dev/null @@ -1,219 +0,0 @@ -// 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; -using System.Collections.Generic; -using Xunit; - -namespace Microsoft.AspNet.Mvc -{ - public class TypeHelperTests - { - [Theory] - [InlineData(typeof(decimal))] - [InlineData(typeof(Guid))] - public void IsCompatibleWithReturnsFalse_IfValueTypeIsNull(Type type) - { - // Act - bool result = TypeHelper.IsCompatibleWith(type, value: null); - - // Assert - Assert.False(result); - } - - [Theory] - [InlineData(typeof(short))] - [InlineData(typeof(DateTimeOffset))] - [InlineData(typeof(Foo))] - public void IsCompatibleWithReturnsFalse_IfValueIsMismatched(Type type) - { - // Act - bool result = TypeHelper.IsCompatibleWith(type, value: "Hello world"); - - // Assert - Assert.False(result); - } - - public static IEnumerable TypesWithValues - { - get - { - yield return new object[] { typeof(int?), null }; - yield return new object[] { typeof(int), 4 }; - yield return new object[] { typeof(int?), 1 }; - yield return new object[] { typeof(DateTime?), null }; - yield return new object[] { typeof(Guid), Guid.Empty }; - yield return new object[] { typeof(DateTimeOffset?), DateTimeOffset.UtcNow }; - yield return new object[] { typeof(string), null }; - yield return new object[] { typeof(string), "foo string" }; - yield return new object[] { typeof(Foo), null }; - yield return new object[] { typeof(Foo), new Foo() }; - } - } - - [Theory] - [MemberData(nameof(TypesWithValues))] - public void IsCompatibleWithReturnsTrue_IfValueIsAssignable(Type type, object value) - { - // Act - bool result = TypeHelper.IsCompatibleWith(type, value); - - // Assert - Assert.True(result); - } - - private class Foo - { - } - - public static TheoryData> IgnoreCaseTestData - { - get - { - return new TheoryData> - { - { - new - { - selected = true, - SeLeCtEd = false - }, - new KeyValuePair("selected", false) - }, - { - new - { - SeLeCtEd = false, - selected = true - }, - new KeyValuePair("SeLeCtEd", true) - }, - { - new - { - SelECTeD = false, - SeLECTED = true - }, - new KeyValuePair("SelECTeD", true) - } - }; - } - } - - [Theory] - [MemberData(nameof(IgnoreCaseTestData))] - public void ObjectToDictionary_IgnoresPropertyCase(object testObject, - KeyValuePair expectedEntry) - { - // Act - var result = TypeHelper.ObjectToDictionary(testObject); - - // Assert - var entry = Assert.Single(result); - Assert.Equal(expectedEntry, entry); - } - - [Fact] - public void ObjectToDictionary_WithNullObject_ReturnsEmptyDictionary() - { - // Arrange - object value = null; - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(0, dictValues.Count); - } - - [Fact] - public void ObjectToDictionary_WithPlainObjectType_ReturnsEmptyDictionary() - { - // Arrange - var value = new object(); - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(0, dictValues.Count); - } - - [Fact] - public void ObjectToDictionary_WithPrimitiveType_LooksUpPublicProperties() - { - // Arrange - var value = "test"; - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(1, dictValues.Count); - Assert.Equal(4, dictValues["Length"]); - } - - [Fact] - public void ObjectToDictionary_WithAnonymousType_LooksUpProperties() - { - // Arrange - var value = new { test = "value", other = 1 }; - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(2, dictValues.Count); - Assert.Equal("value", dictValues["test"]); - Assert.Equal(1, dictValues["other"]); - } - - [Fact] - public void ObjectToDictionary_ReturnsCaseInsensitiveDictionary() - { - // Arrange - var value = new { TEST = "value", oThEr = 1 }; - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(2, dictValues.Count); - Assert.Equal("value", dictValues["test"]); - Assert.Equal(1, dictValues["other"]); - } - - [Fact] - public void ObjectToDictionary_ReturnsInheritedProperties() - { - // Arrange - var value = new ThreeDPoint() { X = 5, Y = 10, Z = 17 }; - - // Act - var dictValues = TypeHelper.ObjectToDictionary(value); - - // Assert - Assert.NotNull(dictValues); - Assert.Equal(3, dictValues.Count); - Assert.Equal(5, dictValues["X"]); - Assert.Equal(10, dictValues["Y"]); - Assert.Equal(17, dictValues["Z"]); - } - - private class Point - { - public int X { get; set; } - public int Y { get; set; } - } - - private class ThreeDPoint : Point - { - public int Z { get; set; } - } - } -} diff --git a/test/Microsoft.AspNet.Mvc.Common.Test/project.json b/test/Microsoft.AspNet.Mvc.Common.Test/project.json deleted file mode 100644 index df46d2720..000000000 --- a/test/Microsoft.AspNet.Mvc.Common.Test/project.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilationOptions": { - "warningsAsErrors": "true" - }, - "dependencies": { - "Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" }, - "Microsoft.AspNet.Testing": "1.0.0-*", - "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.CopyOnWriteDictionary.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, - "xunit.runner.aspnet": "2.0.0-aspnet-*", - "Microsoft.Framework.DependencyInjection": "1.0.0-*" - }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { - "dependencies": { - "Moq": "4.2.1312.1622" - } - }, - "dnxcore50": { - "dependencies": { - "System.ComponentModel.TypeConverter": "4.0.0-beta-*", - "System.Reflection.Extensions": "4.0.0-beta-*", - "System.Text.Encoding.Extensions": "4.0.10-beta-*" - } - } - } -} diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/OutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/OutputFormatterTests.cs index 21bcdce2e..a398cd43f 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/OutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/OutputFormatterTests.cs @@ -113,9 +113,9 @@ namespace Microsoft.AspNet.Mvc.Test testFormatter.WriteResponseHeaders(formatterContext); // Assert - Assert.Equal(Encodings.UTF16EncodingLittleEndian.WebName, formatterContext.SelectedEncoding.WebName); - Assert.Equal(Encodings.UTF16EncodingLittleEndian, formatterContext.SelectedEncoding); - Assert.Equal("application/doesNotSetContext; charset=" + Encodings.UTF16EncodingLittleEndian.WebName, + Assert.Equal(Encoding.Unicode.WebName, formatterContext.SelectedEncoding.WebName); + Assert.Equal(Encoding.Unicode, formatterContext.SelectedEncoding); + Assert.Equal("application/doesNotSetContext; charset=" + Encoding.Unicode.WebName, formatterContext.SelectedContentType.ToString()); } @@ -307,7 +307,7 @@ namespace Microsoft.AspNet.Mvc.Test public DoesNotSetContext() { SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/doesNotSetContext")); - SupportedEncodings.Add(Encodings.UTF16EncodingLittleEndian); + SupportedEncodings.Add(Encoding.Unicode); } public override bool CanWriteResult(OutputFormatterContext context, MediaTypeHeaderValue contentType) @@ -330,7 +330,7 @@ namespace Microsoft.AspNet.Mvc.Test SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("image/png")); SupportedEncodings.Add(Encoding.UTF8); } - + public override Task WriteResponseBodyAsync([NotNull] OutputFormatterContext context) { return Task.FromResult(true); diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/RedirectToRouteResultTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/RedirectToRouteResultTest.cs index 6474f5c93..01583b630 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/RedirectToRouteResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/RedirectToRouteResultTest.cs @@ -8,6 +8,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Testing; +using Microsoft.Framework.Internal; using Moq; using Xunit; @@ -33,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Core new ActionDescriptor()); var urlHelper = GetMockUrlHelper(expectedUrl); - var result = new RedirectToRouteResult(null, TypeHelper.ObjectToDictionary(values)) + var result = new RedirectToRouteResult(null, PropertyHelper.ObjectToDictionary(values)) { UrlHelper = urlHelper, }; diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperLinkGenerationTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperLinkGenerationTest.cs index a78d1f28f..0f71064e5 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperLinkGenerationTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperLinkGenerationTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.Framework.Internal; using Moq; using Xunit; @@ -148,13 +149,13 @@ namespace Microsoft.AspNet.Mvc.Rendering private string GetRouteValuesAsString(object routeValues) { - var dict = TypeHelper.ObjectToDictionary(routeValues); + var dict = PropertyHelper.ObjectToDictionary(routeValues); return string.Join(string.Empty, dict.Select(kvp => string.Format("{0}={1}", kvp.Key, kvp.Value.ToString()))); } private string GetHtmlAttributesAsString(object routeValues) { - var dict = TypeHelper.ObjectToDictionary(routeValues); + var dict = PropertyHelper.ObjectToDictionary(routeValues); return string.Join(string.Empty, dict.Select(kvp => string.Format(" {0}=\"HtmlEncode[[{1}]]\"", kvp.Key, kvp.Value.ToString()))); } } diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs index d4584e1b0..f07ddf6aa 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs @@ -289,10 +289,10 @@ namespace Microsoft.AspNet.Mvc.Xml var expectedMessage = TestPlatformHelper.IsMono ? "Expected element 'TestLevelTwo' in namespace '', but found Element node 'DummyClass' in namespace ''" : "The expected encoding 'utf-8' does not match the actual encoding 'utf-16LE'."; - var inpStart = Encodings.UTF16EncodingLittleEndian.GetBytes("" + + var inpStart = Encoding.Unicode.GetBytes("" + ""); byte[] inp = { 192, 193 }; - var inpEnd = Encodings.UTF16EncodingLittleEndian.GetBytes(""); + var inpEnd = Encoding.Unicode.GetBytes(""); var contentBytes = new byte[inpStart.Length + inp.Length + inpEnd.Length]; Buffer.BlockCopy(inpStart, 0, contentBytes, 0, inpStart.Length); @@ -316,7 +316,7 @@ namespace Microsoft.AspNet.Mvc.Xml var expectedMessage = TestPlatformHelper.IsMono ? "Expected element 'TestLevelTwo' in namespace '', but found Element node 'DummyClass' in namespace ''" : "The expected encoding 'utf-16LE' does not match the actual encoding 'utf-8'."; - var inputBytes = Encodings.UTF8EncodingWithoutBOM.GetBytes("" + + var inputBytes = Encoding.UTF8.GetBytes("" + "1000"); var formatter = new XmlDataContractSerializerInputFormatter(); @@ -374,13 +374,13 @@ namespace Microsoft.AspNet.Mvc.Xml "" + expectedString + ""; var formatter = new XmlDataContractSerializerInputFormatter(); - var contentBytes = Encodings.UTF16EncodingLittleEndian.GetBytes(input); + var contentBytes = Encoding.Unicode.GetBytes(input); var modelState = new ModelStateDictionary(); var httpContext = GetHttpContext(contentBytes, contentType: "application/xml; charset=utf-16"); var context = new InputFormatterContext(httpContext, modelState, typeof(TestLevelOne)); - + // Act var model = await formatter.ReadAsync(context); diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlSerializerInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlSerializerInputFormatterTest.cs index 418c82918..33d0a3668 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlSerializerInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlSerializerInputFormatterTest.cs @@ -307,10 +307,10 @@ namespace Microsoft.AspNet.Mvc.Xml "There is an error in XML document." : "The expected encoding 'utf-8' does not match the actual encoding 'utf-16LE'."; - var inpStart = Encodings.UTF16EncodingLittleEndian.GetBytes("" + + var inpStart = Encoding.Unicode.GetBytes("" + ""); byte[] inp = { 192, 193 }; - var inpEnd = Encodings.UTF16EncodingLittleEndian.GetBytes(""); + var inpEnd = Encoding.Unicode.GetBytes(""); var contentBytes = new byte[inpStart.Length + inp.Length + inpEnd.Length]; Buffer.BlockCopy(inpStart, 0, contentBytes, 0, inpStart.Length); @@ -335,9 +335,9 @@ namespace Microsoft.AspNet.Mvc.Xml "There is an error in XML document." : "The expected encoding 'utf-16LE' does not match the actual encoding 'utf-8'."; - var inputBytes = Encodings.UTF8EncodingWithoutBOM.GetBytes("" + + var inputBytes = Encoding.UTF8.GetBytes("" + "1000"); - + var formatter = new XmlSerializerInputFormatter(); var modelState = new ModelStateDictionary(); @@ -395,7 +395,7 @@ namespace Microsoft.AspNet.Mvc.Xml "" + expectedDateTime + ""; var formatter = new XmlSerializerInputFormatter(); - var contentBytes = Encodings.UTF16EncodingLittleEndian.GetBytes(input); + var contentBytes = Encoding.Unicode.GetBytes(input); var modelState = new ModelStateDictionary(); var httpContext = GetHttpContext(contentBytes, contentType: "application/xml; charset=utf-16");