diff --git a/AspNetCore.sln b/AspNetCore.sln
index bbc9fd05ae..958e9a61b7 100644
--- a/AspNetCore.sln
+++ b/AspNetCore.sln
@@ -1487,12 +1487,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Diagno
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.JSInterop.Tests", "src\JSInterop\Microsoft.JSInterop\test\Microsoft.JSInterop.Tests.csproj", "{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProtectedBrowserStorage", "ProtectedBrowserStorage", "{1B06FD32-3A1D-46A4-B2AF-99159FAD8127}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.ProtectedBrowserStorage", "src\Components\ProtectedBrowserStorage\src\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj", "{9059AC97-7547-4CC1-A076-680CBCCC1F33}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests", "src\Components\ProtectedBrowserStorage\test\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj", "{943FD3EC-D330-4277-B3F3-3DFABB57D3B5}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Configuration.KeyPerFile", "src\Configuration.KeyPerFile\src\Microsoft.Extensions.Configuration.KeyPerFile.csproj", "{498A4F54-F11A-46C5-A58D-09DE56C6A034}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Configuration.KeyPerFile", "Configuration.KeyPerFile", "{AEB1933E-9369-4305-B20E-F186F888158F}"
@@ -7127,30 +7121,6 @@ Global
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x64.Build.0 = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x86.ActiveCfg = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x86.Build.0 = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|x64.ActiveCfg = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|x64.Build.0 = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|x86.ActiveCfg = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Debug|x86.Build.0 = Debug|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|Any CPU.Build.0 = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|x64.ActiveCfg = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|x64.Build.0 = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|x86.ActiveCfg = Release|Any CPU
- {9059AC97-7547-4CC1-A076-680CBCCC1F33}.Release|x86.Build.0 = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|x64.ActiveCfg = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|x64.Build.0 = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|x86.ActiveCfg = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Debug|x86.Build.0 = Debug|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|Any CPU.Build.0 = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|x64.ActiveCfg = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|x64.Build.0 = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|x86.ActiveCfg = Release|Any CPU
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5}.Release|x86.Build.0 = Release|Any CPU
{498A4F54-F11A-46C5-A58D-09DE56C6A034}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{498A4F54-F11A-46C5-A58D-09DE56C6A034}.Debug|Any CPU.Build.0 = Debug|Any CPU
{498A4F54-F11A-46C5-A58D-09DE56C6A034}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -8053,9 +8023,6 @@ Global
{55CACC1F-FE96-47C8-8073-91F4CAA55C75} = {2A91479A-4ABE-4BB7-9A5E-CA3B9CCFC69E}
{7509AA1E-3093-4BEE-984F-E11579E98A11} = {7CB09412-C9B0-47E8-A8C3-311AA4CFDE04}
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E} = {16898702-3E33-41C1-B8D8-4CE3F1D46BD9}
- {1B06FD32-3A1D-46A4-B2AF-99159FAD8127} = {60D51C98-2CC0-40DF-B338-44154EFEE2FF}
- {9059AC97-7547-4CC1-A076-680CBCCC1F33} = {1B06FD32-3A1D-46A4-B2AF-99159FAD8127}
- {943FD3EC-D330-4277-B3F3-3DFABB57D3B5} = {1B06FD32-3A1D-46A4-B2AF-99159FAD8127}
{498A4F54-F11A-46C5-A58D-09DE56C6A034} = {AEB1933E-9369-4305-B20E-F186F888158F}
{AEB1933E-9369-4305-B20E-F186F888158F} = {017429CC-C5FB-48B4-9C46-034E29EE2F06}
{B9D37BCF-80D1-489D-9FC6-55191FDBB033} = {AEB1933E-9369-4305-B20E-F186F888158F}
diff --git a/eng/ProjectReferences.props b/eng/ProjectReferences.props
index 0e0a9a7c79..43a9982259 100644
--- a/eng/ProjectReferences.props
+++ b/eng/ProjectReferences.props
@@ -140,7 +140,6 @@
-
diff --git a/src/Components/Components.slnf b/src/Components/Components.slnf
index bfb10dcc6f..87f23a36bd 100644
--- a/src/Components/Components.slnf
+++ b/src/Components/Components.slnf
@@ -111,9 +111,7 @@
"src\\Components\\WebAssembly\\Sdk\\src\\Microsoft.NET.Sdk.BlazorWebAssembly.csproj",
"src\\Components\\WebAssembly\\Sdk\\test\\Microsoft.NET.Sdk.BlazorWebAssembly.Tests.csproj",
"src\\Components\\WebAssembly\\Sdk\\integrationtests\\Microsoft.NET.Sdk.BlazorWebAssembly.IntegrationTests.csproj",
- "src\\JSInterop\\Microsoft.JSInterop\\src\\Microsoft.JSInterop.csproj",
- "src\\Components\\ProtectedBrowserStorage\\src\\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj",
- "src\\Components\\ProtectedBrowserStorage\\test\\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj"
+ "src\\JSInterop\\Microsoft.JSInterop\\src\\Microsoft.JSInterop.csproj"
]
}
}
diff --git a/src/Components/ComponentsNoDeps.slnf b/src/Components/ComponentsNoDeps.slnf
index b6e75d5a65..d7918fcc1a 100644
--- a/src/Components/ComponentsNoDeps.slnf
+++ b/src/Components/ComponentsNoDeps.slnf
@@ -45,9 +45,7 @@
"src\\Components\\test\\testassets\\BasicTestApp\\BasicTestApp.csproj",
"src\\Components\\test\\testassets\\ComponentsApp.Server\\ComponentsApp.Server.csproj",
"src\\Components\\test\\testassets\\TestContentPackage\\TestContentPackage.csproj",
- "src\\Components\\test\\testassets\\TestServer\\Components.TestServer.csproj",
- "src\\Components\\ProtectedBrowserStorage\\src\\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj",
- "src\\Components\\ProtectedBrowserStorage\\test\\Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj"
+ "src\\Components\\test\\testassets\\TestServer\\Components.TestServer.csproj"
]
}
}
diff --git a/src/Components/ProtectedBrowserStorage/src/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj b/src/Components/ProtectedBrowserStorage/src/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj
deleted file mode 100644
index 47d821394f..0000000000
--- a/src/Components/ProtectedBrowserStorage/src/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.csproj
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
- $(DefaultNetCoreTargetFramework)
- Provides functionality for storing protected data using the browser's localStorage and sessionStorage APIs.
- true
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Components/ProtectedBrowserStorage/src/Properties/AssemblyInfo.cs b/src/Components/ProtectedBrowserStorage/src/Properties/AssemblyInfo.cs
deleted file mode 100644
index 6c858dd397..0000000000
--- a/src/Components/ProtectedBrowserStorage/src/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-using System.Runtime.CompilerServices;
-using System.Runtime.Versioning;
-
-[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
diff --git a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageServiceCollectionExtensions.cs b/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageServiceCollectionExtensions.cs
deleted file mode 100644
index 8fd43a6ed8..0000000000
--- a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageServiceCollectionExtensions.cs
+++ /dev/null
@@ -1,24 +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 Microsoft.AspNetCore.Components.ProtectedBrowserStorage;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- ///
- /// Extension methods for registering Protected Browser Storage services.
- ///
- public static class ProtectedBrowserStorageServiceCollectionExtensions
- {
- ///
- /// Adds services for protected browser storage to the specified .
- ///
- /// The .
- public static void AddProtectedBrowserStorage(this IServiceCollection services)
- {
- services.AddDataProtection();
- services.AddScoped();
- services.AddScoped();
- }
- }
-}
diff --git a/src/Components/ProtectedBrowserStorage/test/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj b/src/Components/ProtectedBrowserStorage/test/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj
deleted file mode 100644
index 04c21cbd13..0000000000
--- a/src/Components/ProtectedBrowserStorage/test/Microsoft.AspNetCore.Components.ProtectedBrowserStorage.Tests.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- $(DefaultNetCoreTargetFramework)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs b/src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs
index d3868d082b..f87dc13928 100644
--- a/src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs
+++ b/src/Components/Server/src/DependencyInjection/ComponentServiceCollectionExtensions.cs
@@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Components.Server.BlazorPack;
using Microsoft.AspNetCore.Components.Server.Circuits;
+using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.AspNetCore.SignalR.Protocol;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@@ -33,6 +34,9 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddDataProtection();
+ services.TryAddScoped();
+ services.TryAddScoped();
+
// This call INTENTIONALLY uses the AddHubOptions on the SignalR builder, because it will merge
// the global HubOptions before running the configure callback. We want to ensure that happens
// once. Our AddHubOptions method doesn't do this.
diff --git a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
similarity index 95%
rename from src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
rename to src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
index 565d32574b..4445265fff 100644
--- a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
+++ b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorage.cs
@@ -4,19 +4,17 @@
using System;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
-namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+namespace Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
{
///
/// Provides mechanisms for storing and retrieving data in the browser storage.
///
- [UnsupportedOSPlatform("browser")]
public abstract class ProtectedBrowserStorage
{
private readonly string _storeName;
@@ -31,7 +29,7 @@ namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
/// The name of the store in which the data should be stored.
/// The .
/// The .
- protected ProtectedBrowserStorage(string storeName, IJSRuntime jsRuntime, IDataProtectionProvider dataProtectionProvider)
+ private protected ProtectedBrowserStorage(string storeName, IJSRuntime jsRuntime, IDataProtectionProvider dataProtectionProvider)
{
// Performing data protection on the client would give users a false sense of security, so we'll prevent this.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")))
@@ -155,8 +153,8 @@ namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
private ValueTask SetProtectedJsonAsync(string key, string protectedJson)
=> _jsRuntime.InvokeVoidAsync($"{_storeName}.setItem", key, protectedJson);
- private ValueTask GetProtectedJsonAsync(string key)
- => _jsRuntime.InvokeAsync($"{_storeName}.getItem", key);
+ private ValueTask GetProtectedJsonAsync(string key)
+ => _jsRuntime.InvokeAsync($"{_storeName}.getItem", key);
// IDataProtect isn't disposable, so we're fine holding these indefinitely.
// Only a bounded number of them will be created, as the 'key' values should
diff --git a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs
similarity index 65%
rename from src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs
rename to src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs
index 7fa193231f..26abda605c 100644
--- a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs
+++ b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedBrowserStorageResult.cs
@@ -1,14 +1,12 @@
// 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.Diagnostics.CodeAnalysis;
-
-namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+namespace Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
{
///
/// Contains the result of a protected browser storage operation.
///
- public readonly struct ProtectedBrowserStorageResult
+ public readonly struct ProtectedBrowserStorageResult
{
///
/// Gets whether the operation succeeded.
@@ -18,11 +16,9 @@ namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
///
/// Gets the result value of the operation.
///
- [MaybeNull]
- [AllowNull]
- public T Value { get; }
+ public TValue? Value { get; }
- internal ProtectedBrowserStorageResult(bool success, [AllowNull] T value)
+ internal ProtectedBrowserStorageResult(bool success, TValue? value)
{
Success = success;
Value = value;
diff --git a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs
similarity index 84%
rename from src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs
rename to src/Components/Server/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs
index badaaaea95..0d606b5419 100644
--- a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs
+++ b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedLocalStorage.cs
@@ -1,11 +1,10 @@
// 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.Runtime.Versioning;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
-namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+namespace Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
{
///
/// Provides mechanisms for storing and retrieving data in the browser's
@@ -16,8 +15,7 @@ namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
///
- [UnsupportedOSPlatform("browser")]
- public class ProtectedLocalStorage : ProtectedBrowserStorage
+ public sealed class ProtectedLocalStorage : ProtectedBrowserStorage
{
///
/// Constructs an instance of .
diff --git a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs
similarity index 85%
rename from src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs
rename to src/Components/Server/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs
index 35fb9d7ea4..274179f70f 100644
--- a/src/Components/ProtectedBrowserStorage/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs
+++ b/src/Components/Server/src/ProtectedBrowserStorage/ProtectedSessionStorage.cs
@@ -1,11 +1,10 @@
// 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.Runtime.Versioning;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
-namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+namespace Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
{
///
/// Provides mechanisms for storing and retrieving data in the browser's
@@ -16,8 +15,7 @@ namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
///
/// See: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
///
- [UnsupportedOSPlatform("browser")]
- public class ProtectedSessionStorage : ProtectedBrowserStorage
+ public sealed class ProtectedSessionStorage : ProtectedBrowserStorage
{
///
/// Constructs an instance of .
diff --git a/src/Components/ProtectedBrowserStorage/test/ProtectedBrowserStorageTest.cs b/src/Components/Server/test/ProtectedBrowserStorageTest.cs
similarity index 99%
rename from src/Components/ProtectedBrowserStorage/test/ProtectedBrowserStorageTest.cs
rename to src/Components/Server/test/ProtectedBrowserStorageTest.cs
index f5a752d9a3..3e5f8f4a58 100644
--- a/src/Components/ProtectedBrowserStorage/test/ProtectedBrowserStorageTest.cs
+++ b/src/Components/Server/test/ProtectedBrowserStorageTest.cs
@@ -14,7 +14,7 @@ using Microsoft.AspNetCore.WebUtilities;
using Microsoft.JSInterop;
using Xunit;
-namespace Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+namespace Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
{
public class ProtectedBrowserStorageTest
{
diff --git a/src/Components/test/E2ETest/Infrastructure/WebDriverExtensions/BasicTestAppWebDriverExtensions.cs b/src/Components/test/E2ETest/Infrastructure/WebDriverExtensions/BasicTestAppWebDriverExtensions.cs
index 1d744ab26d..77b77275bd 100644
--- a/src/Components/test/E2ETest/Infrastructure/WebDriverExtensions/BasicTestAppWebDriverExtensions.cs
+++ b/src/Components/test/E2ETest/Infrastructure/WebDriverExtensions/BasicTestAppWebDriverExtensions.cs
@@ -8,7 +8,10 @@ namespace Microsoft.AspNetCore.Components.E2ETest
{
public static IWebElement MountTestComponent(this IWebDriver browser) where TComponent : IComponent
{
- var componentTypeName = typeof(TComponent).FullName;
+ var componentType = typeof(TComponent);
+ var componentTypeName = componentType.Assembly == typeof(BasicTestApp.Program).Assembly ?
+ componentType.FullName :
+ componentType.AssemblyQualifiedName;
var testSelector = browser.WaitUntilTestSelectorReady();
testSelector.SelectByValue("none");
testSelector.SelectByValue(componentTypeName);
diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ProtectedBrowserStorageUsageTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/ProtectedBrowserStorageUsageTest.cs
index 5908dffc4b..1e692eff4d 100644
--- a/src/Components/test/E2ETest/ServerExecutionTests/ProtectedBrowserStorageUsageTest.cs
+++ b/src/Components/test/E2ETest/ServerExecutionTests/ProtectedBrowserStorageUsageTest.cs
@@ -5,25 +5,24 @@ using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
-using BasicTestApp;
+using Components.TestServer;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
using Microsoft.AspNetCore.E2ETesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
-using TestServer;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
{
- public class ProtectedBrowserStorageUsageTest : ServerTestBase>
+ public class ProtectedBrowserStorageUsageTest : ServerTestBase>
{
public ProtectedBrowserStorageUsageTest(
BrowserFixture browserFixture,
- BasicTestAppServerSiteFixture serverFixture,
+ ToggleExecutionModeServerFixture serverFixture,
ITestOutputHelper output)
- : base(browserFixture, serverFixture, output)
+ : base(browserFixture, serverFixture.WithServerExecution(), output)
{
}
diff --git a/src/Components/test/E2ETest/Tests/ProtectedBrowserStorageInjectionTest.cs b/src/Components/test/E2ETest/Tests/ProtectedBrowserStorageInjectionTest.cs
index d3ae79c944..2cd415087e 100644
--- a/src/Components/test/E2ETest/Tests/ProtectedBrowserStorageInjectionTest.cs
+++ b/src/Components/test/E2ETest/Tests/ProtectedBrowserStorageInjectionTest.cs
@@ -3,6 +3,7 @@
using System;
using BasicTestApp;
+using Components.TestServer;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
using Microsoft.AspNetCore.E2ETesting;
@@ -10,7 +11,7 @@ using OpenQA.Selenium;
using Xunit;
using Xunit.Abstractions;
-namespace Microsoft.AspNetCore.Components.E2ETest.Tests
+namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
{
public class ProtectedBrowserStorageInjectionTest : ServerTestBase>
{
@@ -18,7 +19,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
BrowserFixture browserFixture,
ToggleExecutionModeServerFixture serverFixture,
ITestOutputHelper output)
- : base(browserFixture, serverFixture, output)
+ : base(browserFixture, serverFixture.WithServerExecution(), output)
{
}
diff --git a/src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj b/src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj
index d25ab75795..13f08442bf 100644
--- a/src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj
+++ b/src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj
@@ -15,7 +15,6 @@
-
diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor
index f2abaa1ba9..d73fb75fbf 100644
--- a/src/Components/test/testassets/BasicTestApp/Index.razor
+++ b/src/Components/test/testassets/BasicTestApp/Index.razor
@@ -66,8 +66,8 @@
-
-
+
+
@@ -108,7 +108,7 @@
string SelectedComponentTypeName { get; set; } = "none";
Type SelectedComponentType
- => SelectedComponentTypeName == "none" ? null : Type.GetType(SelectedComponentTypeName);
+ => SelectedComponentTypeName == "none" ? null : Type.GetType(SelectedComponentTypeName, throwOnError: true);
void RenderSelectedComponent(RenderTreeBuilder builder)
{
@@ -118,4 +118,13 @@
builder.CloseComponent();
}
}
+
+ static string GetTestServerProjectComponent(string componentName)
+ {
+ var serverAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(f => f.GetName().Name == "Components.TestServer");
+ // If the server project isn't loaded return the component name as-is. Calculating the SelectedComponentType property will result in an error.
+ return serverAssembly is null ?
+ componentName :
+ serverAssembly.GetType(componentName, throwOnError: true).AssemblyQualifiedName;
+ }
}
diff --git a/src/Components/test/testassets/BasicTestApp/Program.cs b/src/Components/test/testassets/BasicTestApp/Program.cs
index 09f652e62e..0a33c288da 100644
--- a/src/Components/test/testassets/BasicTestApp/Program.cs
+++ b/src/Components/test/testassets/BasicTestApp/Program.cs
@@ -19,7 +19,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.JSInterop;
-using Microsoft.AspNetCore.Components.ProtectedBrowserStorage;
namespace BasicTestApp
{
@@ -40,11 +39,6 @@ namespace BasicTestApp
policy.RequireAssertion(ctx => ctx.User.Identity.Name?.StartsWith("B") ?? false));
});
- builder.Services.AddDataProtection();
-
- builder.Services.AddTransient();
- builder.Services.AddTransient();
-
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
builder.Logging.Services.AddSingleton(s =>
diff --git a/src/Components/test/testassets/BasicTestApp/wwwroot/index.html b/src/Components/test/testassets/BasicTestApp/wwwroot/index.html
index 584dcc44bb..ed8bf6a89f 100644
--- a/src/Components/test/testassets/BasicTestApp/wwwroot/index.html
+++ b/src/Components/test/testassets/BasicTestApp/wwwroot/index.html
@@ -6,6 +6,7 @@
Basic test app
+
diff --git a/src/Components/test/testassets/TestServer/Components.TestServer.csproj b/src/Components/test/testassets/TestServer/Components.TestServer.csproj
index 5030a5fc78..ebe6254a90 100644
--- a/src/Components/test/testassets/TestServer/Components.TestServer.csproj
+++ b/src/Components/test/testassets/TestServer/Components.TestServer.csproj
@@ -7,7 +7,6 @@
-
diff --git a/src/Components/test/testassets/TestServer/Pages/_ServerHost.cshtml b/src/Components/test/testassets/TestServer/Pages/_ServerHost.cshtml
index 2421d246ad..1276708a8e 100644
--- a/src/Components/test/testassets/TestServer/Pages/_ServerHost.cshtml
+++ b/src/Components/test/testassets/TestServer/Pages/_ServerHost.cshtml
@@ -7,6 +7,7 @@
Basic test app
+
diff --git a/src/Components/test/testassets/TestServer/PrerenderedStartup.cs b/src/Components/test/testassets/TestServer/PrerenderedStartup.cs
index 961333fb6e..c4d7ad3c94 100644
--- a/src/Components/test/testassets/TestServer/PrerenderedStartup.cs
+++ b/src/Components/test/testassets/TestServer/PrerenderedStartup.cs
@@ -23,7 +23,7 @@ namespace TestServer
services.AddMvc();
services.AddServerSideBlazor();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
- services.AddSingleton();
+ services.AddScoped();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
diff --git a/src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageInjectionComponent.razor b/src/Components/test/testassets/TestServer/ProtectedBrowserStorageInjectionComponent.razor
similarity index 82%
rename from src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageInjectionComponent.razor
rename to src/Components/test/testassets/TestServer/ProtectedBrowserStorageInjectionComponent.razor
index 1fc1b40c0d..54ec048f77 100644
--- a/src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageInjectionComponent.razor
+++ b/src/Components/test/testassets/TestServer/ProtectedBrowserStorageInjectionComponent.razor
@@ -1,6 +1,5 @@
-@using Microsoft.Extensions.DependencyInjection
-@using Microsoft.AspNetCore.Components.Web.Extensions
-@using Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+@using Microsoft.Extensions.DependencyInjection
+@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
@inject IServiceProvider ServiceProvider
diff --git a/src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageUsageComponent.razor b/src/Components/test/testassets/TestServer/ProtectedBrowserStorageUsageComponent.razor
similarity index 93%
rename from src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageUsageComponent.razor
rename to src/Components/test/testassets/TestServer/ProtectedBrowserStorageUsageComponent.razor
index fd9c65d4c9..8f9da1a79a 100644
--- a/src/Components/test/testassets/BasicTestApp/ProtectedBrowserStorageUsageComponent.razor
+++ b/src/Components/test/testassets/TestServer/ProtectedBrowserStorageUsageComponent.razor
@@ -1,5 +1,4 @@
-@using Microsoft.AspNetCore.Components.Web.Extensions
-@using Microsoft.AspNetCore.Components.ProtectedBrowserStorage
+@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
@inject ProtectedLocalStorage ProtectedLocalStore
@inject ProtectedSessionStorage ProtectedSessionStore
diff --git a/src/Components/test/testassets/TestServer/ServerStartup.cs b/src/Components/test/testassets/TestServer/ServerStartup.cs
index 90d6e862fa..83578c5dcb 100644
--- a/src/Components/test/testassets/TestServer/ServerStartup.cs
+++ b/src/Components/test/testassets/TestServer/ServerStartup.cs
@@ -19,8 +19,7 @@ namespace TestServer
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
- services.AddServerSideBlazor();
- services.AddProtectedBrowserStorage();
+ services.AddServerSideBlazor(options => options.DetailedErrors = true);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
diff --git a/src/Components/test/testassets/TestServer/_Imports.razor b/src/Components/test/testassets/TestServer/_Imports.razor
new file mode 100644
index 0000000000..a71616835c
--- /dev/null
+++ b/src/Components/test/testassets/TestServer/_Imports.razor
@@ -0,0 +1,2 @@
+@using Microsoft.AspNetCore.Components.Web
+@using Microsoft.AspNetCore.Components.Web.Virtualization