Add AngleSharp with temporary InternalsVisibleTo
This commit is contained in:
parent
604aa14518
commit
75b083911c
14
Blazor.sln
14
Blazor.sln
|
|
@ -54,11 +54,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Browser.JS
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Browser", "src\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj", "{4874AFF4-335D-4037-8858-BBBB987C124B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Browser", "src\Microsoft.Blazor.Browser\Microsoft.Blazor.Browser.csproj", "{4874AFF4-335D-4037-8858-BBBB987C124B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Blazor.Test", "test\Microsoft.Blazor.Test\Microsoft.Blazor.Test.csproj", "{8FD8636E-AFA5-434D-8857-06D02686741A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Blazor.Test", "test\Microsoft.Blazor.Test\Microsoft.Blazor.Test.csproj", "{8FD8636E-AFA5-434D-8857-06D02686741A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testapps", "testapps", "{4AE0D35B-D97A-44D0-8392-C9240377DCCE}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testapps", "testapps", "{4AE0D35B-D97A-44D0-8392-C9240377DCCE}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTestApp", "test\testapps\BasicTestApp\BasicTestApp.csproj", "{2838CB6F-D2C7-4C0A-A994-C72E56F16984}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTestApp", "test\testapps\BasicTestApp\BasicTestApp.csproj", "{2838CB6F-D2C7-4C0A-A994-C72E56F16984}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "anglesharp", "anglesharp", "{4E3BD19A-6159-4548-A88F-700443E6D934}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AngleSharpBuilder", "src\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj", "{36706AC2-C851-4038-B161-9C1E44B668C8}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -146,6 +150,10 @@ Global
|
||||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{36706AC2-C851-4038-B161-9C1E44B668C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{36706AC2-C851-4038-B161-9C1E44B668C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{36706AC2-C851-4038-B161-9C1E44B668C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{36706AC2-C851-4038-B161-9C1E44B668C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -175,6 +183,8 @@ Global
|
||||||
{8FD8636E-AFA5-434D-8857-06D02686741A} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
|
{8FD8636E-AFA5-434D-8857-06D02686741A} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
|
||||||
{4AE0D35B-D97A-44D0-8392-C9240377DCCE} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
|
{4AE0D35B-D97A-44D0-8392-C9240377DCCE} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
|
||||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984} = {4AE0D35B-D97A-44D0-8392-C9240377DCCE}
|
{2838CB6F-D2C7-4C0A-A994-C72E56F16984} = {4AE0D35B-D97A-44D0-8392-C9240377DCCE}
|
||||||
|
{4E3BD19A-6159-4548-A88F-700443E6D934} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
||||||
|
{36706AC2-C851-4038-B161-9C1E44B668C8} = {4E3BD19A-6159-4548-A88F-700443E6D934}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
|
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,9 @@
|
||||||
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
|
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj" ReferenceOutputAssembly="false" />
|
||||||
|
<Reference Include="AngleSharp" HintPath="..\anglesharp\AngleSharpBuilder\dist\AngleSharp.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
dist/
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AngleSharp" Version="0.9.9.1" />
|
||||||
|
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="GenerateDist" AfterTargets="Build">
|
||||||
|
<Exec WorkingDirectory="$(MSBuildThisFileDirectory)" Command="dotnet $(OutDir)$(AssemblyName).dll" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
// 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 AngleSharp.Parser.Html;
|
||||||
|
using Mono.Cecil;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace AngleSharpBuilder
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* AngleSharp's HtmlTokenizer is perfect for the RazorCompiler use case of splitting up
|
||||||
|
* incomplete HTML strings into partial elements, attributes, etc. Unfortunately,
|
||||||
|
* AngleSharp does not expose HtmlTokenizer publicly.
|
||||||
|
*
|
||||||
|
* For now, we work around this by building a custom version of AngleSharp.dll that
|
||||||
|
* specifies [InternalsVisibleTo("Microsoft.Blazor.Build")]. Longer term we can ask
|
||||||
|
* AngleSharp to expose HtmlTokenizer as a public API, and if that's not viable, possibly
|
||||||
|
* replace AngleSharp with a different library for HTML tokenization.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
var outputDir = Path.Combine(Directory.GetCurrentDirectory(), "dist");
|
||||||
|
var angleSharpAssembly = Assembly.GetAssembly(typeof(HtmlParser));
|
||||||
|
WriteWithInternalsVisibleTo(
|
||||||
|
angleSharpAssembly,
|
||||||
|
"Microsoft.Blazor.Build",
|
||||||
|
outputDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteWithInternalsVisibleTo(Assembly assembly, string internalVisibleToArg, string outputDir)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(outputDir);
|
||||||
|
|
||||||
|
var assemblyLocation = assembly.Location;
|
||||||
|
var moduleDefinition = ModuleDefinition.ReadModule(assemblyLocation);
|
||||||
|
|
||||||
|
var internalsVisibleToCtor = moduleDefinition.ImportReference(
|
||||||
|
typeof(InternalsVisibleToAttribute).GetConstructor(new[] { typeof(string) }));
|
||||||
|
|
||||||
|
var customAttribute = new CustomAttribute(internalsVisibleToCtor);
|
||||||
|
customAttribute.ConstructorArguments.Add(
|
||||||
|
new CustomAttributeArgument(moduleDefinition.TypeSystem.String, internalVisibleToArg));
|
||||||
|
|
||||||
|
moduleDefinition.Assembly.CustomAttributes.Add(customAttribute);
|
||||||
|
|
||||||
|
moduleDefinition.Write(Path.Combine(outputDir, Path.GetFileName(assemblyLocation)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AngleSharp" Version="0.9.9" />
|
<PackageReference Include="AngleSharp" Version="0.9.9.1" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.6.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
||||||
<PackageReference Include="xunit" Version="2.3.1" />
|
<PackageReference Include="xunit" Version="2.3.1" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue