Update Anglesharp
This commit is contained in:
parent
5dc5404570
commit
54eda39cb8
14
Blazor.sln
14
Blazor.sln
|
|
@ -50,10 +50,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testapps", "testapps", "{4A
|
|||
EndProject
|
||||
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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AngleSharpBuilder", "src\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj", "{36706AC2-C851-4038-B161-9C1E44B668C8}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Razor.Extensions", "src\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj", "{D652A019-B765-4922-B7B8-3AB1C58338D7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Browser.Test", "test\Microsoft.AspNetCore.Blazor.Browser.Test\Microsoft.AspNetCore.Blazor.Browser.Test.csproj", "{EC2A38BF-6E77-4A8E-A731-15929544F29C}"
|
||||
|
|
@ -227,14 +223,6 @@ Global
|
|||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2838CB6F-D2C7-4C0A-A994-C72E56F16984}.ReleaseNoVSIX|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}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{36706AC2-C851-4038-B161-9C1E44B668C8}.DebugNoVSIX|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
|
||||
{36706AC2-C851-4038-B161-9C1E44B668C8}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{36706AC2-C851-4038-B161-9C1E44B668C8}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
|
||||
{D652A019-B765-4922-B7B8-3AB1C58338D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D652A019-B765-4922-B7B8-3AB1C58338D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D652A019-B765-4922-B7B8-3AB1C58338D7}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -374,8 +362,6 @@ Global
|
|||
{8FD8636E-AFA5-434D-8857-06D02686741A} = {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}
|
||||
{4E3BD19A-6159-4548-A88F-700443E6D934} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
||||
{36706AC2-C851-4038-B161-9C1E44B668C8} = {4E3BD19A-6159-4548-A88F-700443E6D934}
|
||||
{D652A019-B765-4922-B7B8-3AB1C58338D7} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
||||
{EC2A38BF-6E77-4A8E-A731-15929544F29C} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
|
||||
{29CD3FC6-49E3-4756-B5DF-E03B46E5CD45} = {4AE0D35B-D97A-44D0-8392-C9240377DCCE}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,5 @@
|
|||
<!-- the 'DebugNoVSIX' and 'ReleaseNoVSIX' configurations exclude the VSIX project, which doesn't build with Microsoft.NET.Sdk yet. -->
|
||||
<AdditionalProperties>Configuration=$(Configuration)NoVSIX</AdditionalProperties>
|
||||
</Solutions>
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Get Anglesharp built right away. This isn't needed for correctness, but helps avoid concurrency problems.
|
||||
-->
|
||||
<Target Name="BuildAngleSharp" BeforeTargets="BuildSolutions">
|
||||
<Message Importance="High" Text="Building Anglesharp..." />
|
||||
<MSBuild Projects="$(MSBuildThisFileDirectory)..\src\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj" />
|
||||
</Target>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// 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;
|
||||
using AngleSharp.Extensions;
|
||||
using AngleSharp.Html;
|
||||
using AngleSharp.Parser.Html;
|
||||
using Mono.Cecil;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AngleSharp;
|
||||
using AngleSharp.Html;
|
||||
using AngleSharp.Parser.Html;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace Microsoft.AspNetCore.Blazor.Build
|
||||
{
|
||||
|
|
@ -109,15 +110,14 @@ namespace Microsoft.AspNetCore.Blazor.Build
|
|||
|
||||
// Search for a tag of the form <script type="boot-blazor"></script>, and replace
|
||||
// it with a fully-configured Blazor boot script tag
|
||||
var tokenizer = new HtmlTokenizer(
|
||||
new TextSource(htmlTemplate),
|
||||
HtmlEntityService.Resolver);
|
||||
var textSource = new TextSource(htmlTemplate);
|
||||
var currentRangeStartPos = 0;
|
||||
var isInBlazorBootTag = false;
|
||||
var resumeOnNextToken = false;
|
||||
while (true)
|
||||
var result = string.Empty;
|
||||
|
||||
foreach (var token in textSource.Tokenize(HtmlEntityService.Resolver))
|
||||
{
|
||||
var token = tokenizer.Get();
|
||||
var tokenCharIndex = token.Position.Position - 1;
|
||||
if (resumeOnNextToken)
|
||||
{
|
||||
|
|
@ -181,9 +181,13 @@ namespace Microsoft.AspNetCore.Blazor.Build
|
|||
{
|
||||
resultBuilder.Append(htmlTemplate, currentRangeStartPos, remainingLength);
|
||||
}
|
||||
return resultBuilder.ToString();
|
||||
result = resultBuilder.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void AppendReferenceTags(StringBuilder resultBuilder, IEnumerable<string> urls, string format)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<RepositoryUrl>$(RepositoryUrl)</RepositoryUrl>
|
||||
<Category>$(PackageArtifactCategory)</Category>
|
||||
<Certificate>$(PackageSigningCertName)</Certificate>
|
||||
<ShouldBeSigned Condition="'$(PackageSigningCertName)' != '' OR @(SignedPackageFile->Count()) != 0 ">true</ShouldBeSigned>
|
||||
<ShouldBeSigned Condition="'$(PackageSigningCertName)' != '' OR @(SignedPackageFile->Count()) != 0 ">true</ShouldBeSigned>
|
||||
<ShouldBeSigned Condition=" '$(DisableCodeSigning)' == 'true' ">false</ShouldBeSigned>
|
||||
<IsContainer>true</IsContainer>
|
||||
</ArtifactInfo>
|
||||
|
|
@ -67,6 +67,7 @@
|
|||
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Browser.JS\Microsoft.AspNetCore.Blazor.Browser.JS.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Blazor\Microsoft.AspNetCore.Blazor.csproj" />
|
||||
<PackageReference Include="AngleSharp" Version="0.9.9.2" />
|
||||
|
||||
<!-- Intentionally include Razor.Design's MSBuild assets for everyone who reference Blazor.Build -->
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="$(RazorPackageVersion)" PrivateAssets="None" />
|
||||
|
|
@ -77,8 +78,4 @@
|
|||
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta7" />
|
||||
<PackageReference Include="System.CodeDom" Version="4.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="..\anglesharp\AngleSharpBuilder\dist\Microsoft.AspNetCore.Blazor.AngleSharp.dll" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project>
|
||||
<Project>
|
||||
|
||||
<!-- Require rebuild if the targets change -->
|
||||
<PropertyGroup>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<!-- Passed to Razor tasks and loaded as a plugin -->
|
||||
<_BlazorAngleSharpAssemblyPath>$(MSBuildThisFileDirectory)../tools/Microsoft.AspNetCore.Blazor.AngleSharp.dll</_BlazorAngleSharpAssemblyPath>
|
||||
<_AngleSharpAssemblyPath>$(MSBuildThisFileDirectory)../tools/AngleSharp.dll</_AngleSharpAssemblyPath>
|
||||
<_BlazorExtensionAssemblyPath>$(MSBuildThisFileDirectory)../tools/Microsoft.AspNetCore.Blazor.Razor.Extensions.dll</_BlazorExtensionAssemblyPath>
|
||||
|
||||
<!-- Deactivates the Razor SDK's build-time compilation. We do our own -->
|
||||
|
|
@ -55,8 +55,8 @@
|
|||
</RazorConfiguration>
|
||||
|
||||
<RazorExtension Include="Blazor.AngleSharp-$(BlazorLanguageVersion)">
|
||||
<AssemblyName>Microsoft.AspNetCore.Blazor.AngleSharp</AssemblyName>
|
||||
<AssemblyFilePath>$(_BlazorAngleSharpAssemblyPath)</AssemblyFilePath>
|
||||
<AssemblyName>AngleSharp</AssemblyName>
|
||||
<AssemblyFilePath>$(_AngleSharpAssemblyPath)</AssemblyFilePath>
|
||||
</RazorExtension>
|
||||
<RazorExtension Include="Blazor-$(BlazorLanguageVersion)">
|
||||
<AssemblyName>Microsoft.AspNetCore.Blazor.Razor.Extensions</AssemblyName>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
// 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;
|
||||
using AngleSharp.Extensions;
|
||||
using AngleSharp.Html;
|
||||
using AngleSharp.Parser.Html;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AngleSharp;
|
||||
using AngleSharp.Html;
|
||||
using AngleSharp.Parser.Html;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Blazor.Razor
|
||||
{
|
||||
|
|
@ -80,7 +81,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
|
|||
RewriteChildren(_source, node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void VisitHtmlAttribute(HtmlAttributeIntermediateNode node)
|
||||
{
|
||||
// Don't rewrite inside of attributes
|
||||
|
|
@ -123,19 +124,23 @@ namespace Microsoft.AspNetCore.Blazor.Razor
|
|||
// the attributes from the parsed HTML and the CSharpAttribute value.
|
||||
var parser = new HtmlParser(source);
|
||||
var attributes = new List<HtmlAttributeIntermediateNode>();
|
||||
|
||||
|
||||
for (var i = 0; i < children.Length; i++)
|
||||
{
|
||||
if (children[i] is HtmlContentIntermediateNode htmlNode)
|
||||
{
|
||||
parser.Push(htmlNode);
|
||||
|
||||
while (true)
|
||||
var tokens = parser.Get();
|
||||
foreach (var token in tokens)
|
||||
{
|
||||
// We have to call this before get. Anglesharp doesn't return the start position
|
||||
// of tokens.
|
||||
var start = parser.GetCurrentLocation();
|
||||
var token = parser.Get();
|
||||
|
||||
// We have to set the Location explicitly otherwise we would need to include
|
||||
// the token in every call to the parser.
|
||||
parser.SetLocation(token);
|
||||
|
||||
var end = parser.GetCurrentLocation();
|
||||
|
||||
if (token.Type == HtmlTokenType.EndOfFile)
|
||||
|
|
@ -349,7 +354,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
|
|||
|
||||
// Tracks the offsets between the start of _content and then original source document.
|
||||
private List<(int offset, int sourceOffset)> _offsets;
|
||||
private HtmlTokenizer _tokenizer;
|
||||
private TextSource _textSource;
|
||||
private int _position;
|
||||
private string _content;
|
||||
|
||||
|
|
@ -382,7 +387,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
|
|||
|
||||
_content = builder.ToString();
|
||||
_offsets = offsets;
|
||||
_tokenizer = new HtmlTokenizer(new TextSource(_content), HtmlEntityService.Resolver);
|
||||
_textSource = new TextSource(_content);
|
||||
_position = 0;
|
||||
}
|
||||
|
||||
|
|
@ -391,23 +396,25 @@ namespace Microsoft.AspNetCore.Blazor.Razor
|
|||
return _position >= _content.Length ? string.Empty : _content.Substring(_position);
|
||||
}
|
||||
|
||||
public HtmlToken Get()
|
||||
public IEnumerable<HtmlToken> Get()
|
||||
{
|
||||
if (_tokenizer == null)
|
||||
if (_textSource == null)
|
||||
{
|
||||
throw new InvalidOperationException("You need to call Push first.");
|
||||
}
|
||||
|
||||
var token = _tokenizer.Get();
|
||||
var tokens = _textSource.Tokenize(HtmlEntityService.Resolver);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
public void SetLocation(HtmlToken token)
|
||||
{
|
||||
// The tokenizer will advance to the end when you have an unclosed tag.
|
||||
// We don't want this, we want to resume before the unclosed tag.
|
||||
if (token.Type != HtmlTokenType.EndOfFile)
|
||||
{
|
||||
_position = _tokenizer.Position;
|
||||
_position = _textSource.Index;
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public SourceLocation GetCurrentLocation(int offset = 0)
|
||||
|
|
|
|||
|
|
@ -10,20 +10,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngleSharp" Version="0.9.9.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="$(RazorPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Razor" Version="$(RazorPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj">
|
||||
<Name>AngleSharpBuilder</Name>
|
||||
<Private>False</Private>
|
||||
<SetTargetFramework>TargetFramework=netcoreapp2.0</SetTargetFramework>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<Reference Include="..\anglesharp\AngleSharpBuilder\dist\Microsoft.AspNetCore.Blazor.AngleSharp.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
dist/
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<IsPackable>false</IsPackable>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</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"
|
||||
Inputs="$(MSBuildAllProjects);$(OutDir)$(AssemblyName).dll"
|
||||
Outputs="$(MSBuildThisFileDirectory)dist\Microsoft.AspNetCore.Blazor.AngleSharp.dll">
|
||||
<Exec WorkingDirectory="$(MSBuildThisFileDirectory)" Command="dotnet $(OutDir)$(AssemblyName).dll" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,117 +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 AngleSharp.Parser.Html;
|
||||
using Mono.Cecil;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
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.AspNetCore.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.
|
||||
*
|
||||
* Similarly, we have build-process reasons for needing the assembly not to be strong
|
||||
* named and be called Microsoft.AspNetCore.Blazor.AngleSharp. These requirements will
|
||||
* not be permanent but it enables progress in the short term.
|
||||
*/
|
||||
|
||||
public static class Program
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
// Prevent concurrent execution of this program. Since this is called by MSBuild
|
||||
// make sure to wait for other instances to exit, we need the file to exist when
|
||||
// this program exits.
|
||||
using (var mutex = new Mutex(true, "AngleSharpBuilder", out var created))
|
||||
{
|
||||
if (created)
|
||||
{
|
||||
try
|
||||
{
|
||||
var outputDir = Path.Combine(Directory.GetCurrentDirectory(), "dist");
|
||||
var inputAssembly = Assembly.GetAssembly(typeof(HtmlParser));
|
||||
WriteModifiedAssembly(inputAssembly, outputDir);
|
||||
}
|
||||
finally
|
||||
{
|
||||
mutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Waiting for AngleSharpBuilder to exit...");
|
||||
mutex.WaitOne(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteModifiedAssembly(Assembly assembly, string outputDir)
|
||||
{
|
||||
Directory.CreateDirectory(outputDir);
|
||||
|
||||
var assemblyLocation = assembly.Location;
|
||||
var moduleDefinition = ModuleDefinition.ReadModule(assemblyLocation);
|
||||
|
||||
AddInternalsVisibleTo(moduleDefinition, "Microsoft.AspNetCore.Blazor.Build");
|
||||
AddInternalsVisibleTo(moduleDefinition, "Microsoft.AspNetCore.Blazor.Razor.Extensions");
|
||||
RemoveStrongName(moduleDefinition);
|
||||
SetAssemblyName(moduleDefinition, "Microsoft.AspNetCore.Blazor.AngleSharp");
|
||||
|
||||
// Try to minimize the chance of a parallel build reading the assembly in an
|
||||
// incomplete state by writing it to a temp location then moving the result.
|
||||
// There's still a race condition here, but hopefully this is enough to stop
|
||||
// it from surfacing in practice.
|
||||
|
||||
var tempFilePath = Path.GetTempFileName();
|
||||
moduleDefinition.Write(tempFilePath);
|
||||
|
||||
var outputPath = Path.Combine(outputDir, $"{moduleDefinition.Name}.dll");
|
||||
try
|
||||
{
|
||||
File.Delete(outputPath);
|
||||
File.Move(tempFilePath, outputPath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(tempFilePath); // In case it didn't get moved above
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetAssemblyName(ModuleDefinition moduleDefinition, string name)
|
||||
{
|
||||
moduleDefinition.Name = name;
|
||||
moduleDefinition.Assembly.Name.Name = name;
|
||||
}
|
||||
|
||||
private static void RemoveStrongName(ModuleDefinition moduleDefinition)
|
||||
{
|
||||
var assemblyName = moduleDefinition.Assembly.Name;
|
||||
assemblyName.HasPublicKey = false;
|
||||
assemblyName.PublicKey = new byte[0];
|
||||
moduleDefinition.Attributes &= ~ModuleAttributes.StrongNameSigned;
|
||||
}
|
||||
|
||||
private static void AddInternalsVisibleTo(ModuleDefinition moduleDefinition, string internalVisibleToArg)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngleSharp" Version="0.9.9.2" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.0-beta3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
|
|
@ -40,9 +41,7 @@
|
|||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\anglesharp\AngleSharpBuilder\AngleSharpBuilder.csproj" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj" />
|
||||
<Reference Include="Microsoft.AspNetCore.Blazor.AngleSharp" HintPath="..\..\src\anglesharp\AngleSharpBuilder\dist\Microsoft.AspNetCore.Blazor.AngleSharp.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
|
||||
|
|
@ -156,8 +156,8 @@
|
|||
This is built as a P2P by Microsoft.VisualStudio.LanguageServices.Blazor. This is required, adding the P2P
|
||||
to this project will cause a NU1201 error that doesn't have a workaround.
|
||||
-->
|
||||
<Content Include="..\..\src\anglesharp\AngleSharpBuilder\dist\Microsoft.AspNetCore.Blazor.AngleSharp.dll">
|
||||
<Link>Microsoft.AspNetCore.Blazor.AngleSharp.dll</Link>
|
||||
<Content Include="bin\$(Configuration)\AngleSharp.dll">
|
||||
<Link>AngleSharp.dll</Link>
|
||||
<IncludeInVSIX>true</IncludeInVSIX>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Visible>false</Visible>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// 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 Microsoft.VisualStudio.Shell;
|
||||
|
|
@ -8,13 +8,6 @@ using Microsoft.VisualStudio.Shell;
|
|||
//
|
||||
// The versions here need to match what the build is producing. If you change the version numbers
|
||||
// for the Blazor assemblies, this needs to change as well.
|
||||
[assembly: ProvideBindingRedirection(
|
||||
AssemblyName = "Microsoft.AspNetCore.Blazor.AngleSharp",
|
||||
GenerateCodeBase = true,
|
||||
PublicKeyToken = "",
|
||||
OldVersionLowerBound = "0.0.0.0",
|
||||
OldVersionUpperBound = "0.9.9.0",
|
||||
NewVersion = "0.9.9.0")]
|
||||
[assembly: ProvideBindingRedirection(
|
||||
AssemblyName = "Microsoft.AspNetCore.Blazor.Razor.Extensions",
|
||||
GenerateCodeBase = true,
|
||||
|
|
@ -29,3 +22,9 @@ using Microsoft.VisualStudio.Shell;
|
|||
OldVersionLowerBound = "0.0.0.0",
|
||||
OldVersionUpperBound = "0.4.0.0",
|
||||
NewVersion = "0.4.0.0")]
|
||||
[assembly: ProvideBindingRedirection(
|
||||
AssemblyName = "AngleSharp",
|
||||
PublicKeyToken = "",
|
||||
OldVersionLowerBound = "0.0.0.0",
|
||||
OldVersionUpperBound = "0.9.9.0",
|
||||
NewVersion = "0.9.9.0")]
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<Assets>
|
||||
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
|
||||
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="File" Path="Microsoft.VisualStudio.LanguageServices.Blazor.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.AspNetCore.Blazor.AngleSharp.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="AngleSharp.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.AspNetCore.Blazor.Razor.Extensions.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="Microsoft.VisualStudio.LanguageServices.Blazor.dll" />
|
||||
<Asset Type="Microsoft.VisualStudio.VsPackage" Path="Templates.pkgdef" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue