Merge remote-tracking branch 'internal/internal/release/2.2' into release/2.2
This commit is contained in:
commit
de52994381
|
|
@ -146,6 +146,8 @@
|
||||||
<MicrosoftCodeAnalysisCSharpPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpPackageVersion>
|
<MicrosoftCodeAnalysisCSharpPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpPackageVersion>
|
||||||
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>2.8.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
|
||||||
<MicrosoftCSharpPackageVersion>4.5.0</MicrosoftCSharpPackageVersion>
|
<MicrosoftCSharpPackageVersion>4.5.0</MicrosoftCSharpPackageVersion>
|
||||||
|
<MicrosoftDataODataPackageVersion>5.8.4</MicrosoftDataODataPackageVersion>
|
||||||
|
<MicrosoftDataServicesClientPackageVersion>5.8.4</MicrosoftDataServicesClientPackageVersion>
|
||||||
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
|
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
|
||||||
<MicrosoftDotNetArchivePackageVersion>0.2.0-beta-63019-01</MicrosoftDotNetArchivePackageVersion>
|
<MicrosoftDotNetArchivePackageVersion>0.2.0-beta-63019-01</MicrosoftDotNetArchivePackageVersion>
|
||||||
<MicrosoftDotNetProjectModelPackageVersion>1.0.0-rc3-003121</MicrosoftDotNetProjectModelPackageVersion>
|
<MicrosoftDotNetProjectModelPackageVersion>1.0.0-rc3-003121</MicrosoftDotNetProjectModelPackageVersion>
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@
|
||||||
<ExternalDependency Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCorePackageVersion)" />
|
<ExternalDependency Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCorePackageVersion)" />
|
||||||
<ExternalDependency Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
|
<ExternalDependency Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
|
||||||
<ExternalDependency Include="Microsoft.Internal.AspNetCore.H2Spec.All" Version="$(MicrosoftInternalAspNetCoreH2SpecAllPackageVersion)" />
|
<ExternalDependency Include="Microsoft.Internal.AspNetCore.H2Spec.All" Version="$(MicrosoftInternalAspNetCoreH2SpecAllPackageVersion)" />
|
||||||
|
<ExternalDependency Include="Microsoft.Data.OData" Version="$(MicrosoftDataODataPackageVersion)" />
|
||||||
|
<ExternalDependency Include="Microsoft.Data.Services.Client" Version="$(MicrosoftDataServicesClientPackageVersion)" />
|
||||||
|
|
||||||
<!-- Razor uses a custom version of roslyn packages -->
|
<!-- Razor uses a custom version of roslyn packages -->
|
||||||
<ExternalDependency Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonPackageVersion)" />
|
<ExternalDependency Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonPackageVersion)" />
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ and are generated based on the last package release.
|
||||||
<LatestPackageReference Include="IdentityServer4" Version="$(IdentityServer4PackageVersion)" />
|
<LatestPackageReference Include="IdentityServer4" Version="$(IdentityServer4PackageVersion)" />
|
||||||
<LatestPackageReference Include="MessagePack" Version="$(MessagePackPackageVersion)" />
|
<LatestPackageReference Include="MessagePack" Version="$(MessagePackPackageVersion)" />
|
||||||
<LatestPackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
<LatestPackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||||
|
<LatestPackageReference Include="Microsoft.Data.OData" Version="$(MicrosoftDataODataPackageVersion)" />
|
||||||
|
<LatestPackageReference Include="Microsoft.Data.Services.Client" Version="$(MicrosoftDataServicesClientPackageVersion)" />
|
||||||
<LatestPackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
<LatestPackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||||
<!-- This version is required by MSBuild tasks or Visual Studio extensions. -->
|
<!-- This version is required by MSBuild tasks or Visual Studio extensions. -->
|
||||||
<LatestPackageReference Include="Newtonsoft.Json" Version="9.0.1" Condition="'$(UseMSBuildJsonNet)' == 'true'" />
|
<LatestPackageReference Include="Newtonsoft.Json" Version="9.0.1" Condition="'$(UseMSBuildJsonNet)' == 'true'" />
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ Later on, this will be checked using this condition:
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.7' ">
|
<PropertyGroup Condition=" '$(VersionPrefix)' == '2.2.7' ">
|
||||||
<PackagesInPatch>
|
<PackagesInPatch>
|
||||||
|
Microsoft.AspNetCore.DataProtection.AzureStorage;
|
||||||
Microsoft.AspNetCore.Hosting;
|
Microsoft.AspNetCore.Hosting;
|
||||||
|
Microsoft.AspNetCore.SpaServices;
|
||||||
</PackagesInPatch>
|
</PackagesInPatch>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Microsoft Azure Blob storrage support as key store.</Description>
|
<Description>Microsoft Azure Blob storage support as key store.</Description>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<PackageTags>aspnetcore;dataprotection;azure;blob</PackageTags>
|
<PackageTags>aspnetcore;dataprotection;azure;blob</PackageTags>
|
||||||
|
<UseLatestPackageReferences>true</UseLatestPackageReferences>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.AspNetCore.DataProtection" />
|
<Reference Include="Microsoft.AspNetCore.DataProtection" />
|
||||||
<Reference Include="WindowsAzure.Storage" />
|
<Reference Include="WindowsAzure.Storage" />
|
||||||
|
<Reference Include="Microsoft.Data.OData" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
<Reference Include="Microsoft.AspNetCore.DataProtection" />
|
<Reference Include="Microsoft.AspNetCore.DataProtection" />
|
||||||
<Reference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" />
|
<Reference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" />
|
||||||
<Reference Include="Microsoft.Extensions.DependencyInjection" />
|
<Reference Include="Microsoft.Extensions.DependencyInjection" />
|
||||||
|
<Reference Include="Microsoft.Data.OData"/>
|
||||||
|
<Reference Include="Microsoft.Data.Services.Client"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
{
|
{
|
||||||
|
|
@ -49,12 +50,16 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
||||||
|
|
||||||
foreach (var property in Globals.Properties())
|
foreach (var property in Globals.Properties())
|
||||||
{
|
{
|
||||||
stringBuilder.AppendFormat("window.{0} = {1};",
|
var propertyNameJavaScriptString = JavaScriptEncoder.Default.Encode(property.Name);
|
||||||
property.Name,
|
var valueJson = property.Value.ToString(Formatting.None);
|
||||||
property.Value.ToString(Formatting.None));
|
var valueJsonJavaScriptString = JavaScriptEncoder.Default.Encode(valueJson);
|
||||||
|
|
||||||
|
stringBuilder.AppendFormat("window[\"{0}\"] = JSON.parse(\"{1}\");",
|
||||||
|
propertyNameJavaScriptString,
|
||||||
|
valueJsonJavaScriptString);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringBuilder.ToString();
|
return stringBuilder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.AspNetCore.SpaServices" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
// 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.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.SpaServices.Tests
|
||||||
|
{
|
||||||
|
public class RenderToStringResultTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void HandlesNullGlobals()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var renderToStringResult = new RenderToStringResult();
|
||||||
|
renderToStringResult.Globals = null;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actualScript = renderToStringResult.CreateGlobalsAssignmentScript();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(string.Empty, actualScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void HandlesGlobalsWithMultipleProperties()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var renderToStringResult = new RenderToStringResult();
|
||||||
|
renderToStringResult.Globals = ToJObject(new
|
||||||
|
{
|
||||||
|
FirstProperty = "first value",
|
||||||
|
SecondProperty = new[] { "Array entry 0", "Array entry 1" }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actualScript = renderToStringResult.CreateGlobalsAssignmentScript();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var expectedScript = @"window[""FirstProperty""] = JSON.parse(""\u0022first value\u0022"");" +
|
||||||
|
@"window[""SecondProperty""] = JSON.parse(""[\u0022Array entry 0\u0022,\u0022Array entry 1\u0022]"");";
|
||||||
|
Assert.Equal(expectedScript, actualScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void HandlesGlobalsWithCorrectStringEncoding()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var renderToStringResult = new RenderToStringResult();
|
||||||
|
renderToStringResult.Globals = ToJObject(new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "Va<l'u\"e", "</tag>\"'}\u260E" }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var actualScript = renderToStringResult.CreateGlobalsAssignmentScript();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var expectedScript = @"window[""Va\u003Cl\u0027u\u0022e""] = JSON.parse(""\u0022\u003C\/tag\u003E\\\u0022\u0027}\u260E\u0022"");";
|
||||||
|
Assert.Equal(expectedScript, actualScript);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JObject ToJObject(object value)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<JObject>(JsonConvert.SerializeObject(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue