- Removed TaskHelper and refactored with ClosedGenericMatcher
 - Removed TypeHelper
 - Moved custom encodings to InputFormatter
 - Moved ObjectToDictionary to PropertyHelper
 - Removed respective tests and test projects
This commit is contained in:
Ajay Bhargav Baaskaran 2015-06-12 11:04:32 -07:00
Родитель 9e68537649
Коммит a3cbb1f378
55 изменённых файлов: 197 добавлений и 658 удалений

Просмотреть файл

@ -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}

28
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}

Просмотреть файл

@ -317,7 +317,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
/// </summary>
public bool IsNullableValueType
{
get { return TypeHelper.IsNullableValueType(ModelType); }
get
{
return Nullable.GetUnderlyingType(ModelType) != null;
}
}
/// <summary>

Просмотреть файл

@ -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" },

Просмотреть файл

@ -358,7 +358,7 @@ namespace Microsoft.AspNet.Mvc.ApiExplorer
}
// Unwrap the type if it's a Task<T>. 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

Просмотреть файл

@ -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": {

Просмотреть файл

@ -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
{
/// <summary>
/// Returns UTF8 Encoding without BOM and throws on invalid bytes.
/// </summary>
public static readonly Encoding UTF8EncodingWithoutBOM
= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
/// <summary>
/// Returns UTF16 Encoding which uses littleEndian byte order with BOM and throws on invalid bytes.
/// </summary>
public static readonly Encoding UTF16EncodingLittleEndian = new UnicodeEncoding(bigEndian: false,
byteOrderMark: true,
throwOnInvalidBytes: true);
}
}

Просмотреть файл

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>f3df6d0b-16fe-4402-b92c-7243a75cf1fd</ProjectGuid>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

Просмотреть файл

@ -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
{
/// <summary>
/// Utility methods for dealing with <see cref="Task"/>.
/// </summary>
internal static class TaskHelper
{
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Invoking this method is equivalent to calling Wait() on the <paramref name="task" /> if it is not completed.
/// </remarks>
public static void WaitAndThrowIfFaulted(Task task)
{
task.GetAwaiter().GetResult();
}
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Invoking this method is equivalent to calling <see cref="Task{TResult}.Result"/> on the
/// <paramref name="task"/> if it is not completed.
/// </remarks>
public static TVal WaitAndThrowIfFaulted<TVal>(Task<TVal> task)
{
return task.GetAwaiter().GetResult();
}
}
}

Просмотреть файл

@ -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;
}
/// <summary>
/// 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 <see cref="IDictionary{string, object}"/> instance, then a copy
/// is returned.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
public static IDictionary<string, object> ObjectToDictionary(object value)
{
var dictionary = value as IDictionary<string, object>;
if (dictionary != null)
{
return new Dictionary<string, object>(dictionary, StringComparer.OrdinalIgnoreCase);
}
dictionary = new Dictionary<string, object>(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);
}
}
}

Просмотреть файл

@ -1,15 +0,0 @@
{
"version": "6.0.0-*",
"shared": "*.cs",
"dependencies": {
},
"frameworks": {
"net45": { },
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.20-beta-*"
}
}
}
}

Просмотреть файл

@ -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<T> 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];
}
}
}

Просмотреть файл

@ -112,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.Core
}
// Unwrap potential Task<T> 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];
}
}
}

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -17,6 +17,18 @@ namespace Microsoft.AspNet.Mvc
/// </summary>
public abstract class InputFormatter : IInputFormatter
{
/// <summary>
/// Returns UTF8 Encoding without BOM and throws on invalid bytes.
/// </summary>
protected static readonly Encoding UTF8EncodingWithoutBOM
= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
/// <summary>
/// Returns UTF16 Encoding which uses littleEndian byte order with BOM and throws on invalid bytes.
/// </summary>
protected static readonly Encoding UTF16EncodingLittleEndian
= new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true);
/// <summary>
/// Gets the mutable collection of character encodings supported by
/// this <see cref="InputFormatter"/>. The encodings are

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -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());
}
}
}
}

Просмотреть файл

@ -46,7 +46,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
/// </summary>
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));
}
}
}

Просмотреть файл

@ -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));
}
}
}

Просмотреть файл

@ -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"));
}

Просмотреть файл

@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Mvc
/// <inheritdoc />
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
/// <inheritdoc />
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)

Просмотреть файл

@ -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-*",

Просмотреть файл

@ -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
};
/// <summary>
@ -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
{

Просмотреть файл

@ -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,

Просмотреть файл

@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc
{
ActionName = actionName;
ControllerName = controllerName;
RouteValues = TypeHelper.ObjectToDictionary(routeValues);
RouteValues = PropertyHelper.ObjectToDictionary(routeValues);
StatusCode = StatusCodes.Status201Created;
}

Просмотреть файл

@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc
: base(value)
{
RouteName = routeName;
RouteValues = TypeHelper.ObjectToDictionary(routeValues);
RouteValues = PropertyHelper.ObjectToDictionary(routeValues);
StatusCode = StatusCodes.Status201Created;
}

Просмотреть файл

@ -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"));

Просмотреть файл

@ -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"));
}

Просмотреть файл

@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc
bool permanent)
{
RouteName = routeName;
RouteValues = TypeHelper.ObjectToDictionary(routeValues);
RouteValues = PropertyHelper.ObjectToDictionary(routeValues);
Permanent = permanent;
}

Просмотреть файл

@ -148,7 +148,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// <returns>The created dictionary of property names and property values.</returns>
public static IDictionary<string, object> ObjectToDictionary(object value)
{
return TypeHelper.ObjectToDictionary(value);
return PropertyHelper.ObjectToDictionary(value);
}
/// <summary>

Просмотреть файл

@ -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();
}
/// <summary>

Просмотреть файл

@ -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();
}
}

Просмотреть файл

@ -50,7 +50,7 @@ namespace Microsoft.AspNet.Mvc
public void Execute([NotNull] ViewComponentContext context)
{
var task = ExecuteAsync(context);
TaskHelper.WaitAndThrowIfFaulted(task);
task.GetAwaiter().GetResult();
}
/// <summary>

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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
};
/// <summary>
@ -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
{

Просмотреть файл

@ -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" },

Просмотреть файл

@ -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();
}
/// <summary>

Просмотреть файл

@ -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-*",

Просмотреть файл

@ -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));
}
}
}

Просмотреть файл

@ -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; }

Просмотреть файл

@ -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" },

Просмотреть файл

@ -30,8 +30,8 @@ namespace Microsoft.AspNet.Mvc.Xml
/// </summary>
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"));

Просмотреть файл

@ -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
/// <param name="writerSettings">The settings to be used by the <see cref="DataContractSerializer"/>.</param>
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"));

Просмотреть файл

@ -29,8 +29,8 @@ namespace Microsoft.AspNet.Mvc.Xml
/// </summary>
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"));

Просмотреть файл

@ -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
/// <param name="writerSettings">The settings to be used by the <see cref="XmlSerializer"/>.</param>
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"));

Просмотреть файл

@ -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" },

Просмотреть файл

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>0449d6d2-be1b-4e29-8e1b-444420802c03</ProjectGuid>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

Просмотреть файл

@ -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<Exception>(() => 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<Exception>(() => TaskHelper.WaitAndThrowIfFaulted(task));
Assert.Equal(message, ex.Message);
}
private static Task CreatingFailingTask(string message)
{
return Task.Run(() =>
{
throw new Exception(message);
});
}
}
}

Просмотреть файл

@ -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<object[]> 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<object, KeyValuePair<string, object>> IgnoreCaseTestData
{
get
{
return new TheoryData<object, KeyValuePair<string, object>>
{
{
new
{
selected = true,
SeLeCtEd = false
},
new KeyValuePair<string, object>("selected", false)
},
{
new
{
SeLeCtEd = false,
selected = true
},
new KeyValuePair<string, object>("SeLeCtEd", true)
},
{
new
{
SelECTeD = false,
SeLECTED = true
},
new KeyValuePair<string, object>("SelECTeD", true)
}
};
}
}
[Theory]
[MemberData(nameof(IgnoreCaseTestData))]
public void ObjectToDictionary_IgnoresPropertyCase(object testObject,
KeyValuePair<string, object> 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; }
}
}
}

Просмотреть файл

@ -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-*"
}
}
}
}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,
};

Просмотреть файл

@ -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())));
}
}

Просмотреть файл

@ -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("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" +
var inpStart = Encoding.Unicode.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" +
"<DummyClass><SampleInt>");
byte[] inp = { 192, 193 };
var inpEnd = Encodings.UTF16EncodingLittleEndian.GetBytes("</SampleInt></DummyClass>");
var inpEnd = Encoding.Unicode.GetBytes("</SampleInt></DummyClass>");
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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
var inputBytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<DummyClass><SampleInt>1000</SampleInt></DummyClass>");
var formatter = new XmlDataContractSerializerInputFormatter();
@ -374,7 +374,7 @@ namespace Microsoft.AspNet.Mvc.Xml
"<sampleString>" + expectedString + "</sampleString></TestLevelOne>";
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");

Просмотреть файл

@ -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("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" +
var inpStart = Encoding.Unicode.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" +
"<DummyClass><SampleInt>");
byte[] inp = { 192, 193 };
var inpEnd = Encodings.UTF16EncodingLittleEndian.GetBytes("</SampleInt></DummyClass>");
var inpEnd = Encoding.Unicode.GetBytes("</SampleInt></DummyClass>");
var contentBytes = new byte[inpStart.Length + inp.Length + inpEnd.Length];
Buffer.BlockCopy(inpStart, 0, contentBytes, 0, inpStart.Length);
@ -335,7 +335,7 @@ 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("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
var inputBytes = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<DummyClass><SampleInt>1000</SampleInt></DummyClass>");
var formatter = new XmlSerializerInputFormatter();
@ -395,7 +395,7 @@ namespace Microsoft.AspNet.Mvc.Xml
"<SampleDate>" + expectedDateTime + "</SampleDate></TestLevelOne>";
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");