Skip to content

Commit

Permalink
Rename ComponentPlatform to RendererInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercn committed Jun 17, 2024
1 parent c283d05 commit c1cfe2e
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/Components/Components/src/ComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public ComponentBase()
}

/// <summary>
/// Gets the <see cref="ComponentPlatform"/> the component is running on.
/// Gets the <see cref="Components.RendererInfo"/> the component is running on.
/// </summary>
protected ComponentPlatform Platform => _renderHandle.Platform;
protected RendererInfo RendererInfo => _renderHandle.RendererInfo;

/// <summary>
/// Gets the <see cref="ResourceAssetCollection"/> for the application.
Expand Down
14 changes: 7 additions & 7 deletions src/Components/Components/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#nullable enable
Microsoft.AspNetCore.Components.ComponentBase.Assets.get -> Microsoft.AspNetCore.Components.ResourceAssetCollection!
Microsoft.AspNetCore.Components.ComponentBase.AssignedRenderMode.get -> Microsoft.AspNetCore.Components.IComponentRenderMode?
Microsoft.AspNetCore.Components.ComponentBase.Platform.get -> Microsoft.AspNetCore.Components.ComponentPlatform!
Microsoft.AspNetCore.Components.ComponentPlatform
Microsoft.AspNetCore.Components.ComponentPlatform.ComponentPlatform(string! platformName, bool isInteractive) -> void
Microsoft.AspNetCore.Components.ComponentPlatform.IsInteractive.get -> bool
Microsoft.AspNetCore.Components.ComponentPlatform.Name.get -> string!
Microsoft.AspNetCore.Components.ComponentBase.RendererInfo.get -> Microsoft.AspNetCore.Components.RendererInfo!
Microsoft.AspNetCore.Components.ExcludeFromInteractiveRoutingAttribute
Microsoft.AspNetCore.Components.ExcludeFromInteractiveRoutingAttribute.ExcludeFromInteractiveRoutingAttribute() -> void
Microsoft.AspNetCore.Components.RendererInfo
Microsoft.AspNetCore.Components.RendererInfo.IsInteractive.get -> bool
Microsoft.AspNetCore.Components.RendererInfo.Name.get -> string!
Microsoft.AspNetCore.Components.RendererInfo.RendererInfo(string! rendererName, bool isInteractive) -> void
Microsoft.AspNetCore.Components.RenderHandle.Assets.get -> Microsoft.AspNetCore.Components.ResourceAssetCollection!
Microsoft.AspNetCore.Components.RenderHandle.Platform.get -> Microsoft.AspNetCore.Components.ComponentPlatform!
Microsoft.AspNetCore.Components.RenderHandle.RendererInfo.get -> Microsoft.AspNetCore.Components.RendererInfo!
Microsoft.AspNetCore.Components.RenderHandle.RenderMode.get -> Microsoft.AspNetCore.Components.IComponentRenderMode?
Microsoft.AspNetCore.Components.ResourceAsset
Microsoft.AspNetCore.Components.ResourceAsset.Properties.get -> System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Components.ResourceAssetProperty!>?
Expand All @@ -25,4 +25,4 @@ Microsoft.AspNetCore.Components.ResourceAssetProperty.ResourceAssetProperty(stri
Microsoft.AspNetCore.Components.ResourceAssetProperty.Value.get -> string!
static readonly Microsoft.AspNetCore.Components.ResourceAssetCollection.Empty -> Microsoft.AspNetCore.Components.ResourceAssetCollection!
virtual Microsoft.AspNetCore.Components.RenderTree.Renderer.Assets.get -> Microsoft.AspNetCore.Components.ResourceAssetCollection!
virtual Microsoft.AspNetCore.Components.RenderTree.Renderer.ComponentPlatform.get -> Microsoft.AspNetCore.Components.ComponentPlatform!
virtual Microsoft.AspNetCore.Components.RenderTree.Renderer.RendererInfo.get -> Microsoft.AspNetCore.Components.RendererInfo!
4 changes: 2 additions & 2 deletions src/Components/Components/src/RenderHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public Dispatcher Dispatcher
?? throw new InvalidOperationException("No renderer has been initialized.");

/// <summary>
/// Gets the <see cref="ComponentPlatform"/> the component is running on.
/// Gets the <see cref="Components.RendererInfo"/> the component is running on.
/// </summary>
public ComponentPlatform Platform => _renderer?.ComponentPlatform ?? throw new InvalidOperationException("No renderer has been initialized.");
public RendererInfo RendererInfo => _renderer?.RendererInfo ?? throw new InvalidOperationException("No renderer has been initialized.");

/// <summary>
/// Retrieves the <see cref="IComponentRenderMode"/> assigned to the component.
Expand Down
31 changes: 0 additions & 31 deletions src/Components/Components/src/RenderTree/ComponentPlatform.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Components/Components/src/RenderTree/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ protected internal ComponentState GetComponentState(IComponent component)
=> _componentStateByComponent.GetValueOrDefault(component);

/// <summary>
/// Gets the <see cref="ComponentPlatform"/> associated with this <see cref="Renderer"/>.
/// Gets the <see cref="RendererInfo"/> associated with this <see cref="Renderer"/>.
/// </summary>
protected internal virtual ComponentPlatform ComponentPlatform { get; }
protected internal virtual RendererInfo RendererInfo { get; }

/// <summary>
/// Gets the <see cref="ResourceAssetCollection"/> associated with this <see cref="Renderer"/>.
Expand Down
23 changes: 23 additions & 0 deletions src/Components/Components/src/RenderTree/RendererInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Components;

/// <summary>
/// Provides information about the platform that the component is running on.
/// </summary>
/// <param name="rendererName">The name of the platform.</param>
/// <param name="isInteractive">A flag to indicate if the platform is interactive.</param>
public sealed class RendererInfo(string rendererName, bool isInteractive)
{

/// <summary>
/// Gets the name of the platform.
/// </summary>
public string Name { get; } = rendererName;

/// <summary>
/// Gets a flag to indicate if the platform is interactive.
/// </summary>
public bool IsInteractive { get; } = isInteractive;
}
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 @@ -18,7 +18,7 @@ internal partial class RemoteRenderer : WebRenderer
#pragma warning restore CA1852 // Seal internal types
{
private static readonly Task CanceledTask = Task.FromCanceled(new CancellationToken(canceled: true));
private static readonly ComponentPlatform _componentPlatform = new("Server", isInteractive: true);
private static readonly RendererInfo _componentPlatform = new("Server", isInteractive: true);

private readonly CircuitClientProxy _client;
private readonly CircuitOptions _options;
Expand Down Expand Up @@ -62,7 +62,7 @@ public RemoteRenderer(

protected override ResourceAssetCollection Assets => _resourceCollection ?? base.Assets;

protected override ComponentPlatform ComponentPlatform => _componentPlatform;
protected override RendererInfo RendererInfo => _componentPlatform;

protected override IComponentRenderMode? GetComponentRenderMode(IComponent component) => RenderMode.InteractiveServer;

Expand Down
4 changes: 2 additions & 2 deletions src/Components/Web/src/HtmlRendering/StaticHtmlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure;
/// </summary>
public partial class StaticHtmlRenderer : Renderer
{
private static readonly ComponentPlatform _componentPlatform = new ComponentPlatform("Static", isInteractive: false);
private static readonly RendererInfo _componentPlatform = new RendererInfo("Static", isInteractive: false);

private static readonly Task CanceledRenderTask = Task.FromCanceled(new CancellationToken(canceled: true));
private readonly NavigationManager? _navigationManager;
Expand All @@ -41,7 +41,7 @@ public StaticHtmlRenderer(IServiceProvider serviceProvider, ILoggerFactory logge
public override Dispatcher Dispatcher { get; } = Dispatcher.CreateDefault();

/// <inheritdoc/>
protected internal override ComponentPlatform ComponentPlatform => _componentPlatform;
protected internal override RendererInfo RendererInfo => _componentPlatform;

/// <summary>
/// Adds a root component of the specified type and begins rendering it.
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Web/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Microsoft.AspNetCore.Components.Web.Internal.IInternalWebJSInProcessRuntime
Microsoft.AspNetCore.Components.Web.Internal.IInternalWebJSInProcessRuntime.InvokeJS(string! identifier, string? argsJson, Microsoft.JSInterop.JSCallResultType resultType, long targetInstanceId) -> string!
Microsoft.AspNetCore.Components.Web.KeyboardEventArgs.IsComposing.get -> bool
Microsoft.AspNetCore.Components.Web.KeyboardEventArgs.IsComposing.set -> void
override Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.ComponentPlatform.get -> Microsoft.AspNetCore.Components.ComponentPlatform!
override Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.RendererInfo.get -> Microsoft.AspNetCore.Components.RendererInfo!
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal sealed partial class WebAssemblyRenderer : WebRenderer
private readonly Dispatcher _dispatcher;
private readonly ResourceAssetCollection _resourceCollection;
private readonly IInternalJSImportMethods _jsMethods;
private static readonly ComponentPlatform _componentPlatform = new("WebAssembly", isInteractive: true);
private static readonly RendererInfo _componentPlatform = new("WebAssembly", isInteractive: true);

public WebAssemblyRenderer(IServiceProvider serviceProvider, ResourceAssetCollection resourceCollection, ILoggerFactory loggerFactory, JSComponentInterop jsComponentInterop)
: base(serviceProvider, loggerFactory, DefaultWebAssemblyJSRuntime.Instance.ReadJsonSerializerOptions(), jsComponentInterop)
Expand Down Expand Up @@ -85,7 +85,7 @@ public void NotifyEndUpdateRootComponents(long batchId)

protected override ResourceAssetCollection Assets => _resourceCollection;

protected override ComponentPlatform ComponentPlatform => _componentPlatform;
protected override RendererInfo RendererInfo => _componentPlatform;

public override Dispatcher Dispatcher => _dispatcher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Components.WebView.Services;

internal sealed class WebViewRenderer : WebRenderer
{
private static readonly ComponentPlatform _componentPlatform = new("WebView", isInteractive: true);
private static readonly RendererInfo _componentPlatform = new("WebView", isInteractive: true);
private readonly Queue<UnacknowledgedRenderBatch> _unacknowledgedRenderBatches = new();
private readonly Dispatcher _dispatcher;
private readonly IpcSender _ipcSender;
Expand All @@ -32,7 +32,7 @@ public WebViewRenderer(

public override Dispatcher Dispatcher => _dispatcher;

protected override ComponentPlatform ComponentPlatform => _componentPlatform;
protected override RendererInfo RendererInfo => _componentPlatform;

protected override int GetWebRendererId() => (int)WebRendererId.WebView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ else

<p>
Interactive:
<strong id="is-interactive">@Platform.IsInteractive</strong>
<strong id="is-interactive">@RendererInfo.IsInteractive</strong>
</p>


<p>
Platform:
<strong id="platform">@Platform.Name</strong>
<strong id="platform">@RendererInfo.Name</strong>
</p>

<hr />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
_renderMode = "static";
}

if (Platform.IsInteractive)
if (RendererInfo.IsInteractive)
{
_isInteractive = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
@using Microsoft.AspNetCore.Components.Web;
@inject IJSRuntime JSRuntime

<p id="platform-name">@Platform.Name</p>
<p id="platform-name">@RendererInfo.Name</p>

<p id="basic-app-styles">@Assets["BasicTestApp.styles.css"]</p>

@if (!Platform.IsInteractive)
@if (!RendererInfo.IsInteractive)
{
<button id="import-module" onclick="import('./Index.mjs')">Import JS Module</button>
}else
Expand Down

0 comments on commit c1cfe2e

Please sign in to comment.