Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 8ca2728

Browse files
Split encoders into two packages to resolve layering issues
The core package has no external dependencies aside from NetFX-produced packages
1 parent a06d05f commit 8ca2728

25 files changed

+77
-30
lines changed

HttpAbstractions.sln

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22609.0
4+
VisualStudioVersion = 14.0.22710.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A5A15F1C-885A-452A-A731-B0173DDBD913}"
77
EndProject
@@ -41,6 +41,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.WebEnco
4141
EndProject
4242
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.WebEncoders.Tests", "test\Microsoft.Framework.WebEncoders.Tests\Microsoft.Framework.WebEncoders.Tests.xproj", "{7AE2731D-43CD-4CF8-850A-4914DE2CE930}"
4343
EndProject
44+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.WebEncoders.Core", "src\Microsoft.Framework.WebEncoders.Core\Microsoft.Framework.WebEncoders.Core.xproj", "{BE9112CB-D87D-4080-9CC3-24492D49CBE6}"
45+
EndProject
4446
Global
4547
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4648
Debug|Any CPU = Debug|Any CPU
@@ -229,6 +231,18 @@ Global
229231
{7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|Mixed Platforms.Build.0 = Release|Any CPU
230232
{7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|x86.ActiveCfg = Release|Any CPU
231233
{7AE2731D-43CD-4CF8-850A-4914DE2CE930}.Release|x86.Build.0 = Release|Any CPU
234+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
235+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
236+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
237+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
238+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|x86.ActiveCfg = Debug|Any CPU
239+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Debug|x86.Build.0 = Debug|Any CPU
240+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
241+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|Any CPU.Build.0 = Release|Any CPU
242+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
243+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
244+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|x86.ActiveCfg = Release|Any CPU
245+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6}.Release|x86.Build.0 = Release|Any CPU
232246
EndGlobalSection
233247
GlobalSection(SolutionProperties) = preSolution
234248
HideSolutionNode = FALSE
@@ -251,5 +265,6 @@ Global
251265
{E6BB7AD1-BD10-4A23-B780-F4A86ADF00D1} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
252266
{DD2CE416-765E-4000-A03E-C2FF165DA1B6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
253267
{7AE2731D-43CD-4CF8-850A-4914DE2CE930} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
268+
{BE9112CB-D87D-4080-9CC3-24492D49CBE6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
254269
EndGlobalSection
255270
EndGlobal

src/Microsoft.Framework.WebEncoders/EncoderServiceProviderExtensions.cs renamed to src/Microsoft.Framework.WebEncoders.Core/EncoderServiceProviderExtensions.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,48 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using Microsoft.Framework.DependencyInjection;
65

76
namespace Microsoft.Framework.WebEncoders
87
{
98
/// <summary>
10-
/// Contains extension methods for fetching encoders from a service provider.
9+
/// Contains extension methods for fetching encoders from an <see cref="IServiceProvider"/>.
1110
/// </summary>
1211
public static class EncoderServiceProviderExtensions
1312
{
1413
/// <summary>
15-
/// Retrieves an IHtmlEncoder from a service provider.
14+
/// Retrieves an <see cref="IHtmlEncoder"/> from an <see cref="IServiceProvider"/>.
1615
/// </summary>
1716
/// <remarks>
1817
/// This method is guaranteed never to return null.
19-
/// It will return a default encoder instance if the service provider does not contain one.
18+
/// It will return a default encoder instance if <paramref name="serviceProvider"/> does not contain one or is null.
2019
/// </remarks>
2120
public static IHtmlEncoder GetHtmlEncoder(this IServiceProvider serviceProvider)
2221
{
23-
return serviceProvider?.GetService<IHtmlEncoder>() ?? HtmlEncoder.Default;
22+
return (IHtmlEncoder)serviceProvider?.GetService(typeof(IHtmlEncoder)) ?? HtmlEncoder.Default;
2423
}
2524

2625
/// <summary>
27-
/// Retrieves an IJavaScriptStringEncoder from a service provider.
26+
/// Retrieves an <see cref="IJavaScriptStringEncoder"/> from an <see cref="IServiceProvider"/>.
2827
/// </summary>
2928
/// <remarks>
3029
/// This method is guaranteed never to return null.
31-
/// It will return a default encoder instance if the service provider does not contain one.
30+
/// It will return a default encoder instance if <paramref name="serviceProvider"/> does not contain one or is null.
3231
/// </remarks>
3332
public static IJavaScriptStringEncoder GetJavaScriptStringEncoder(this IServiceProvider serviceProvider)
3433
{
35-
return serviceProvider?.GetService<IJavaScriptStringEncoder>() ?? JavaScriptStringEncoder.Default;
34+
return (IJavaScriptStringEncoder)serviceProvider?.GetService(typeof(IJavaScriptStringEncoder)) ?? JavaScriptStringEncoder.Default;
3635
}
3736

3837
/// <summary>
39-
/// Retrieves an IUrlEncoder from a service provider.
38+
/// Retrieves an <see cref="IUrlEncoder"/> from an <see cref="IServiceProvider"/>.
4039
/// </summary>
4140
/// <remarks>
4241
/// This method is guaranteed never to return null.
43-
/// It will return a default encoder instance if the service provider does not contain one.
42+
/// It will return a default encoder instance if <paramref name="serviceProvider"/> does not contain one or is null.
4443
/// </remarks>
4544
public static IUrlEncoder GetUrlEncoder(this IServiceProvider serviceProvider)
4645
{
47-
return serviceProvider?.GetService<IUrlEncoder>() ?? UrlEncoder.Default;
46+
return (IUrlEncoder)serviceProvider?.GetService(typeof(IUrlEncoder)) ?? UrlEncoder.Default;
4847
}
4948
}
5049
}

src/Microsoft.Framework.WebEncoders/HtmlEncoder.cs renamed to src/Microsoft.Framework.WebEncoders.Core/HtmlEncoder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Runtime.CompilerServices;
88
using System.Threading;
9+
using Microsoft.Framework.Internal;
910

1011
namespace Microsoft.Framework.WebEncoders
1112
{
@@ -50,7 +51,7 @@ public HtmlEncoder(params UnicodeRange[] allowedRanges)
5051
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
5152
/// method will be escaped.
5253
/// </summary>
53-
public HtmlEncoder(ICodePointFilter filter)
54+
public HtmlEncoder([NotNull] ICodePointFilter filter)
5455
: this(new HtmlUnicodeEncoder(CodePointFilter.Wrap(filter)))
5556
{
5657
}

src/Microsoft.Framework.WebEncoders/JavaScriptStringEncoder.cs renamed to src/Microsoft.Framework.WebEncoders.Core/JavaScriptStringEncoder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Runtime.CompilerServices;
88
using System.Threading;
9+
using Microsoft.Framework.Internal;
910

1011
namespace Microsoft.Framework.WebEncoders
1112
{
@@ -50,7 +51,7 @@ public JavaScriptStringEncoder(params UnicodeRange[] allowedRanges)
5051
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
5152
/// method will be escaped.
5253
/// </summary>
53-
public JavaScriptStringEncoder(ICodePointFilter filter)
54+
public JavaScriptStringEncoder([NotNull] ICodePointFilter filter)
5455
: this(new JavaScriptStringUnicodeEncoder(CodePointFilter.Wrap(filter)))
5556
{
5657
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>be9112cb-d87d-4080-9cc3-24492d49cbe6</ProjectGuid>
10+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
11+
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
12+
</PropertyGroup>
13+
<PropertyGroup>
14+
<SchemaVersion>2.0</SchemaVersion>
15+
</PropertyGroup>
16+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
17+
</Project>

src/Microsoft.Framework.WebEncoders/UrlEncoder.cs renamed to src/Microsoft.Framework.WebEncoders.Core/UrlEncoder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Runtime.CompilerServices;
88
using System.Threading;
9+
using Microsoft.Framework.Internal;
910

1011
namespace Microsoft.Framework.WebEncoders
1112
{
@@ -50,7 +51,7 @@ public UrlEncoder(params UnicodeRange[] allowedRanges)
5051
/// set returned by <paramref name="filter"/>'s <see cref="ICodePointFilter.GetAllowedCodePoints"/>
5152
/// method will be escaped.
5253
/// </summary>
53-
public UrlEncoder(ICodePointFilter filter)
54+
public UrlEncoder([NotNull] ICodePointFilter filter)
5455
: this(new UrlUnicodeEncoder(CodePointFilter.Wrap(filter)))
5556
{
5657
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "1.0.0-*",
3+
"description": "Contains core encoders for HTML, JavaScript strings, and URLs.",
4+
"compilationOptions": {
5+
"allowUnsafe": true
6+
},
7+
"dependencies": {
8+
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }
9+
},
10+
"frameworks": {
11+
"net45": { },
12+
"dnx451": { },
13+
"dnxcore50": {
14+
"dependencies": {
15+
"System.ComponentModel": "4.0.0-*",
16+
"System.Diagnostics.Debug": "4.0.10-*",
17+
"System.IO": "4.0.10-*",
18+
"System.Reflection": "4.0.10-*",
19+
"System.Runtime.Extensions": "4.0.10-*",
20+
"System.Threading": "4.0.10-*"
21+
}
22+
}
23+
}
24+
}
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
{
22
"version": "1.0.0-*",
3-
"description": "Contains encoders for HTML, JavaScript, and URLs.",
4-
"compilationOptions": {
5-
"allowUnsafe": true
6-
},
3+
"description": "Contains registration and configuration APIs for the core framework encoders.",
74
"dependencies": {
85
"Microsoft.Framework.DependencyInjection.Interfaces": "1.0.0-*",
96
"Microsoft.Framework.OptionsModel": "1.0.0-*",
10-
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }
7+
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" },
8+
"Microsoft.Framework.WebEncoders.Core": "1.0.0-*"
119
},
1210
"frameworks": {
1311
"net45": { },
1412
"dnx451": { },
15-
"dnxcore50": {
16-
"dependencies": {
17-
"System.Diagnostics.Debug": "4.0.10-beta-*",
18-
"System.IO": "4.0.10-beta-*",
19-
"System.Reflection": "4.0.10-beta-*",
20-
"System.Runtime": "4.0.20-beta-*",
21-
"System.Runtime.Extensions": "4.0.10-beta-*",
22-
"System.Threading": "4.0.10-beta-*"
23-
}
24-
}
13+
"dnxcore50": { }
2514
}
2615
}

0 commit comments

Comments
 (0)