Skip to content

[master] Update dependencies from 2 repositories #13510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
400 changes: 200 additions & 200 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

200 changes: 100 additions & 100 deletions eng/Versions.props

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Analyzers/Analyzers/test/AnalyzerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Analyzer.Testing;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.CodeAnalysis;

namespace Microsoft.AspNetCore.Analyzers
Expand Down
1 change: 0 additions & 1 deletion src/Components/Analyzers/test/AnalyzerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Analyzer.Testing;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.CodeAnalysis;

namespace Microsoft.AspNetCore.Components.Analyzers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public Task StartAsync(CancellationToken cancellationToken = default)
// this happens in the browser it will be a direct call from Mono. We effectively needs to set the
// JSRuntime in the 'root' execution context which implies that we want to do as part of a direct
// call from Program.Main, and before any 'awaits'.
JSRuntime.SetCurrentJSRuntime(_runtime);
SetBrowserHttpMessageHandlerAsDefault();

return StartAsyncAwaited();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -13,9 +13,11 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\..\Shared\src\BrowserNavigationManagerInterop.cs" />
<Compile Include="..\..\..\Shared\src\JsonSerializerOptionsProvider.cs" />
<Compile Include="..\..\..\Shared\src\WebEventData.cs" />
<Compile Include="$(ComponentsSharedSourceRoot)src\BrowserNavigationManagerInterop.cs" />
<Compile Include="$(ComponentsSharedSourceRoot)src\JsonSerializerOptionsProvider.cs" />
<Compile Include="$(ComponentsSharedSourceRoot)src\WebEventData.cs" />

<Compile Include="$(ComponentsSharedSourceRoot)src\ElementReferenceJsonConverter.cs" />
</ItemGroup>

</Project>
26 changes: 24 additions & 2 deletions src/Components/Blazor/Blazor/src/Services/WebAssemblyJSRuntime.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
// 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;
using Mono.WebAssembly.Interop;

namespace Microsoft.AspNetCore.Blazor.Services
{
internal static class WebAssemblyJSRuntime
internal sealed class WebAssemblyJSRuntime : MonoWebAssemblyJSRuntime
{
public static readonly MonoWebAssemblyJSRuntime Instance = new MonoWebAssemblyJSRuntime();
private static readonly WebAssemblyJSRuntime _instance = new WebAssemblyJSRuntime();
private static bool _initialized;

public WebAssemblyJSRuntime()
{
JsonSerializerOptions.Converters.Add(new ElementReferenceJsonConverter());
}

public static WebAssemblyJSRuntime Instance
{
get
{
if (!_initialized)
{
// This is executing in MonoWASM. Consequently we do not to have concern ourselves with thread safety.
_initialized = true;
Initialize(_instance);
}

return _instance;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.AspNetCore.Testing;
using Xunit;

namespace Microsoft.AspNetCore.Blazor.Build.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Compile Include="Microsoft.AspNetCore.Components.netstandard2.0.cs" />
<Reference Include="Microsoft.JSInterop" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<Reference Include="System.Buffers" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp5.0'">
<Compile Include="Microsoft.AspNetCore.Components.netcoreapp.cs" />
<Reference Include="Microsoft.JSInterop" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ protected void OnUnhandledException(System.UnhandledExceptionEventArgs e) { }
public readonly partial struct ElementReference
{
private readonly object _dummy;
public ElementReference(string id) { throw null; }
public string Id { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct EventCallback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ protected void OnUnhandledException(System.UnhandledExceptionEventArgs e) { }
public readonly partial struct ElementReference
{
private readonly object _dummy;
public ElementReference(string id) { throw null; }
public string Id { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct EventCallback
Expand Down
50 changes: 2 additions & 48 deletions src/Components/Components/src/ElementReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@

using System;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;

namespace Microsoft.AspNetCore.Components
{
/// <summary>
/// Represents a reference to a rendered element.
/// </summary>
[JsonConverter(typeof(ElementReferenceConverter))]
public readonly struct ElementReference
{
private static long _nextIdForWebAssemblyOnly = 1;
Expand All @@ -24,9 +21,9 @@ public readonly struct ElementReference
/// The Id is unique at least within the scope of a given user/circuit.
/// This property is public to support Json serialization and should not be used by user code.
/// </remarks>
internal string Id { get; }
public string Id { get; }

private ElementReference(string id)
public ElementReference(string id)
{
Id = id;
}
Expand Down Expand Up @@ -54,48 +51,5 @@ private static string CreateUniqueId()
return Guid.NewGuid().ToString("D", CultureInfo.InvariantCulture);
}
}

private sealed class ElementReferenceConverter : JsonConverter<ElementReference>
{
private static readonly JsonEncodedText IdProperty = JsonEncodedText.Encode("__internalId");

public override ElementReference Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string id = null;
while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
{
if (reader.TokenType == JsonTokenType.PropertyName)
{
if (reader.ValueTextEquals(IdProperty.EncodedUtf8Bytes))
{
reader.Read();
id = reader.GetString();
}
else
{
throw new JsonException($"Unexpected JSON property '{reader.GetString()}'.");
}
}
else
{
throw new JsonException($"Unexcepted JSON Token {reader.TokenType}.");
}
}

if (id is null)
{
throw new JsonException("__internalId is required.");
}

return new ElementReference(id);
}

public override void Write(Utf8JsonWriter writer, ElementReference value, JsonSerializerOptions options)
{
writer.WriteStartObject();
writer.WriteString(IdProperty, value.Id);
writer.WriteEndObject();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\Shared\src\JsonSerializerOptionsProvider.cs" />
<Compile Include="$(ComponentsSharedSourceRoot)src\ArrayBuilder.cs" LinkBase="RenderTree" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.JSInterop" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<Reference Include="System.Buffers" />
</ItemGroup>

<Target Name="_GetNuspecDependencyPackageVersions">
<MSBuild Targets="_GetPackageVersionInfo"
BuildInParallel="$(BuildInParallel)"
Expand Down
1 change: 0 additions & 1 deletion src/Components/Components/test/RendererTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.AspNetCore.Components.RenderTree;
using Microsoft.AspNetCore.Components.Test.Helpers;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Abstractions;
using Xunit;

Expand Down
16 changes: 3 additions & 13 deletions src/Components/Server/src/Circuits/CircuitHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.JSInterop;
using Microsoft.JSInterop.Infrastructure;

namespace Microsoft.AspNetCore.Components.Server.Circuits
{
Expand All @@ -25,11 +25,6 @@ internal class CircuitHost : IAsyncDisposable
private bool _initialized;
private bool _disposed;

/// <summary>
/// Sets the <see cref="IJSRuntime"/> for the current excution context.
/// </summary>
public void SetCurrentJSRuntime() => JSInterop.JSRuntime.SetCurrentJSRuntime(JSRuntime);

// This event is fired when there's an unrecoverable exception coming from the circuit, and
// it need so be torn down. The registry listens to this even so that the circuit can
// be torn down even when a client is not connected.
Expand Down Expand Up @@ -100,7 +95,6 @@ public Task InitializeAsync(CancellationToken cancellationToken)

try
{
SetCurrentJSRuntime();
_initialized = true; // We're ready to accept incoming JSInterop calls from here on

await OnCircuitOpenedAsync(cancellationToken);
Expand Down Expand Up @@ -340,9 +334,8 @@ public async Task BeginInvokeDotNetFromJS(string callId, string assemblyName, st
{
await Renderer.Dispatcher.InvokeAsync(() =>
{
SetCurrentJSRuntime();
Log.BeginInvokeDotNet(_logger, callId, assemblyName, methodIdentifier, dotNetObjectId);
DotNetDispatcher.BeginInvoke(callId, assemblyName, methodIdentifier, dotNetObjectId, argsJson);
DotNetDispatcher.BeginInvokeDotNet(JSRuntime, callId, assemblyName, methodIdentifier, dotNetObjectId, argsJson);
});
}
catch (Exception ex)
Expand All @@ -366,7 +359,6 @@ public async Task EndInvokeJSFromDotNet(long asyncCall, bool succeded, string ar
{
await Renderer.Dispatcher.InvokeAsync(() =>
{
SetCurrentJSRuntime();
if (!succeded)
{
// We can log the arguments here because it is simply the JS error with the call stack.
Expand All @@ -377,7 +369,7 @@ await Renderer.Dispatcher.InvokeAsync(() =>
Log.EndInvokeJSSucceeded(_logger, asyncCall);
}

DotNetDispatcher.EndInvoke(arguments);
DotNetDispatcher.EndInvokeJS(JSRuntime, arguments);
});
}
catch (Exception ex)
Expand Down Expand Up @@ -415,7 +407,6 @@ public async Task DispatchEvent(string eventDescriptorJson, string eventArgsJson
{
await Renderer.Dispatcher.InvokeAsync(() =>
{
SetCurrentJSRuntime();
return Renderer.DispatchEventAsync(
webEventData.EventHandlerId,
webEventData.EventFieldInfo,
Expand Down Expand Up @@ -443,7 +434,6 @@ public async Task OnLocationChangedAsync(string uri, bool intercepted)
{
await Renderer.Dispatcher.InvokeAsync(() =>
{
SetCurrentJSRuntime();
Log.LocationChange(_logger, uri, CircuitId);
var navigationManager = (RemoteNavigationManager)Services.GetRequiredService<NavigationManager>();
navigationManager.NotifyLocationChanged(uri, intercepted);
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Server/src/Circuits/RemoteJSRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Microsoft.AspNetCore.Components.Server.Circuits
{
internal class RemoteJSRuntime : JSRuntimeBase
internal class RemoteJSRuntime : JSRuntime
{
private readonly CircuitOptions _options;
private readonly ILogger<RemoteJSRuntime> _logger;
Expand All @@ -22,6 +22,7 @@ public RemoteJSRuntime(IOptions<CircuitOptions> options, ILogger<RemoteJSRuntime
_options = options.Value;
_logger = logger;
DefaultAsyncTimeout = _options.JSInteropDefaultCallTimeout;
JsonSerializerOptions.Converters.Add(new ElementReferenceJsonConverter());
}

internal void Initialize(CircuitClientProxy clientProxy)
Expand Down Expand Up @@ -58,7 +59,7 @@ private void EndInvokeDotNetCore(string callId, bool success, object resultOrErr
{
_clientProxy.SendAsync(
"JS.EndInvokeDotNet",
JsonSerializer.Serialize(new[] { callId, success, resultOrError }, JsonSerializerOptionsProvider.Options));
JsonSerializer.Serialize(new[] { callId, success, resultOrError }, JsonSerializerOptions));
}

protected override void BeginInvokeJS(long asyncHandle, string identifier, string argsJson)
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Server/src/Circuits/RemoteRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public Task AddComponentAsync(Type componentType, string domElementSelector)
var component = InstantiateComponent(componentType);
var componentId = AssignRootComponentId(component);

var attachComponentTask = _jsRuntime.InvokeAsync<object>(
var attachComponentTask = _jsRuntime.InvokeVoidAsync(
"Blazor._internal.attachRootComponentToElement",
domElementSelector,
componentId);
CaptureAsyncExceptions(attachComponentTask);
CaptureAsyncExceptions(attachComponentTask.AsTask());

return RenderRootComponentAsync(componentId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<ItemGroup>
<Compile Include="$(ComponentsSharedSourceRoot)src\CacheHeaderSettings.cs" Link="Shared\CacheHeaderSettings.cs" />
<Compile Include="$(ComponentsSharedSourceRoot)src\ArrayBuilder.cs" LinkBase="Circuits" />
<Compile Include="$(ComponentsSharedSourceRoot)src\ElementReferenceJsonConverter.cs" />

<Compile Include="..\..\Shared\src\BrowserNavigationManagerInterop.cs" />
<Compile Include="..\..\Shared\src\JsonSerializerOptionsProvider.cs" />
Expand Down
1 change: 0 additions & 1 deletion src/Components/Server/test/Circuits/CircuitRegistryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.SignalR;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
Expand Down
8 changes: 2 additions & 6 deletions src/Components/Server/test/Circuits/RemoteRendererTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,8 @@ await renderer.RenderComponentAsync<AutoParameterTestComponent>(
private TestRemoteRenderer GetRemoteRenderer(IServiceProvider serviceProvider, CircuitClientProxy circuitClient = null)
{
var jsRuntime = new Mock<IJSRuntime>();
jsRuntime.Setup(r => r.InvokeAsync<object>(
"Blazor._internal.attachRootComponentToElement",
It.IsAny<int>(),
It.IsAny<string>(),
It.IsAny<int>()))
.ReturnsAsync(Task.FromResult<object>(null));
jsRuntime.Setup(r => r.InvokeAsync<object>("Blazor._internal.attachRootComponentToElement", It.IsAny<object[]>()))
.ReturnsAsync(new ValueTask<object>((object)null));

return new TestRemoteRenderer(
serviceProvider,
Expand Down
Loading