Refactor Encoders into their own package

This commit is contained in:
Levi B 2015-02-22 12:19:22 -08:00
parent 8d98d76209
commit 204fb08e01
23 changed files with 88 additions and 31 deletions

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22513.0
VisualStudioVersion = 14.0.22609.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A5A15F1C-885A-452A-A731-B0173DDBD913}"
EndProject
@ -37,6 +37,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Net.Http.Headers"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Net.Http.Headers.Tests", "test\Microsoft.Net.Http.Headers.Tests\Microsoft.Net.Http.Headers.Tests.kproj", "{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.WebEncoders", "src\Microsoft.Framework.WebEncoders\Microsoft.Framework.WebEncoders.kproj", "{DD2CE416-765E-4000-A03E-C2FF165DA1B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -201,6 +203,18 @@ Global
{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1}.Release|x86.ActiveCfg = Release|Any CPU
{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1}.Release|x86.Build.0 = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Debug|x86.Build.0 = Debug|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Any CPU.Build.0 = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|x86.ActiveCfg = Release|Any CPU
{DD2CE416-765E-4000-A03E-C2FF165DA1B6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -221,5 +235,6 @@ Global
{93C10E50-BCBB-4D8E-9492-D46E1396225B} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
{60AA2FDB-8121-4826-8D00-9A143FEFAF66} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
{DD2CE416-765E-4000-A03E-C2FF165DA1B6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
EndGlobalSection
EndGlobal

View File

@ -5,7 +5,7 @@ using System;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Contains extension methods for fetching encoders from a service provider.

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Specifies options common to all three encoders (HtmlEncode, JavaScriptStringEncode, UrlEncode).
@ -14,8 +14,9 @@ namespace Microsoft.AspNet.WebUtilities.Encoders
/// Specifies code point tables which do not require escaping by the encoders.
/// </summary>
/// <remarks>
/// By default, only Basic Latin is allowed.
/// If this property is set to a null array, then by default only the 'Basic Latin'
/// code point filter is active.
/// </remarks>
public ICodePointFilter[] CodePointFilters { get; set; } = new[] { Microsoft.AspNet.WebUtilities.Encoders.CodePointFilters.BasicLatin };
public ICodePointFilter[] CodePointFilters { get; set; }
}
}

View File

@ -3,7 +3,7 @@
using System;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.WebUtilities.Encoders;
using Microsoft.Framework.WebEncoders;
using Microsoft.Framework.ConfigurationModel;
namespace Microsoft.Framework.DependencyInjection

View File

@ -7,7 +7,7 @@ using Microsoft.Framework.ConfigurationModel;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.OptionsModel;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
public static class EncoderServices
{

View File

@ -3,7 +3,7 @@
"description": "ASP.NET 5 common extension methods for HTTP abstractions and IApplicationBuilder.",
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
"Microsoft.Framework.WebEncoders": "1.0.0-*",
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
"Microsoft.Framework.OptionsModel": "1.0.0-*",
"Microsoft.Net.Http.Headers": "1.0.0-*"

View File

@ -1,9 +1,6 @@
{
"version": "1.0.0-*",
"description": "ASP.NET 5 common helper methods such as URL encoding.",
"compilationOptions": {
"allowUnsafe": true
},
"description": "ASP.NET 5 common helper methods.",
"dependencies": {
},
"frameworks": {
@ -14,11 +11,8 @@
"System.Diagnostics.Debug": "4.0.10-beta-*",
"System.IO": "4.0.10-beta-*",
"System.IO.FileSystem": "4.0.0-beta-*",
"System.Linq": "4.0.0-beta-*",
"System.Reflection.TypeExtensions": "4.0.0-beta-*",
"System.Runtime": "4.0.20-beta-*",
"System.Runtime.Extensions": "4.0.10-beta-*",
"System.Threading": "4.0.10-beta-*"
"System.Runtime.Extensions": "4.0.10-beta-*"
}
}
}

View File

@ -4,11 +4,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Contains predefined Unicode code point filters.
@ -2576,9 +2575,11 @@ namespace Microsoft.AspNet.WebUtilities.Encoders
/// </summary>
private sealed class EmptyCodePointFilter : ICodePointFilter
{
private static readonly int[] _emptyArray = new int[0]; // immutable since empty
public IEnumerable<int> GetAllowedCodePoints()
{
return Enumerable.Empty<int>();
return _emptyArray;
}
}
}

View File

@ -3,7 +3,7 @@
using System;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
internal static class EncoderCommon
{

View File

@ -3,8 +3,9 @@
using System;
using System.IO;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Helpful extension methods for the encoder classes.

View File

@ -5,7 +5,7 @@ using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Contains helpers for dealing with byte-hex char conversions.

View File

@ -6,7 +6,7 @@ using System.Diagnostics;
using System.IO;
using System.Threading;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// A class which can perform HTML encoding given an allow list of characters which

View File

@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Represents a filter which allows only certain Unicode code points through.

View File

@ -4,8 +4,9 @@
using System;
using System.IO;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Provides services for HTML-encoding input.

View File

@ -3,8 +3,9 @@
using System;
using System.IO;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Provides services for JavaScript-escaping strings.

View File

@ -3,8 +3,9 @@
using System;
using System.IO;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Provides services for URL-escaping strings.

View File

@ -6,7 +6,7 @@ using System.Diagnostics;
using System.IO;
using System.Threading;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// A class which can perform JavaScript string escaping given an allow list of characters which

View File

@ -0,0 +1,17 @@
<?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)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>dd2ce416-765e-4000-a03e-c2ff165da1b6</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)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -6,8 +6,9 @@ using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
internal unsafe abstract class UnicodeEncoderBase
{

View File

@ -7,7 +7,7 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// Contains helpers for dealing with Unicode code points.

View File

@ -6,7 +6,7 @@ using System.Diagnostics;
using System.IO;
using System.Threading;
namespace Microsoft.AspNet.WebUtilities.Encoders
namespace Microsoft.Framework.WebEncoders
{
/// <summary>
/// A class which can perform URL string escaping given an allow list of characters which

View File

@ -0,0 +1,24 @@
{
"version": "1.0.0-*",
"description": "Contains encoders for HTML, JavaScript, and URLs.",
"compilationOptions": {
"allowUnsafe": true
},
"dependencies": {
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }
},
"frameworks": {
"net45": { },
"aspnet50": { },
"aspnetcore50": {
"dependencies": {
"System.Diagnostics.Debug": "4.0.10-beta-*",
"System.IO": "4.0.10-beta-*",
"System.Reflection": "4.0.10-beta-*",
"System.Runtime": "4.0.20-beta-*",
"System.Runtime.Extensions": "4.0.10-beta-*",
"System.Threading": "4.0.10-beta-*"
}
}
}
}