Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="BootstrapBlazor.Dom2Image" Version="10.0.1" />
<PackageReference Include="BootstrapBlazor.DriverJs" Version="10.0.1" />
<PackageReference Include="BootstrapBlazor.ElementIcon" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.EmbedPDF" Version="10.0.0-beta04" />
<PackageReference Include="BootstrapBlazor.EmbedPDF" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.FileViewer" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.FluentSystemIcon" Version="10.0.0" />
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="10.0.0" />
Expand Down
14 changes: 7 additions & 7 deletions src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
<Select @bind-Value="_language" Items="_languages"></Select>
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel>TabBarMode</BootstrapInputGroupLabel>
<Select @bind-Value="_tabBarMode"></Select>
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel>Theme</BootstrapInputGroupLabel>
Expand All @@ -39,8 +33,14 @@
<Select @bind-Value="_strategy"></Select>
</BootstrapInputGroup>
</div>
<div class="col-12">
<Button OnClick="@(() => OnSetUrl("sample.pdf"))" Text="Sample.Pdf"></Button>
<Button OnClick="@(() => OnSetUrl("ebook.pdf"))" Text="EBook.Pdf" class="ms-3"></Button>
</div>
</div>
</section>
<EmbedPDF Url="@_url" ViewHeight="600px" Language="@_language"
TabBarMode="_tabBarMode" Theme="_theme" ScrollStrategy="_strategy"></EmbedPDF>
Theme="_theme" ScrollStrategy="_strategy"></EmbedPDF>
</DemoBlock>

<AttributeTable Type="typeof(EmbedPDF)"></AttributeTable>
30 changes: 2 additions & 28 deletions src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace BootstrapBlazor.Server.Components.Samples;
/// </summary>
public partial class EmbedPdfs
{
[Inject, NotNull]
private IWebHostEnvironment? WebHostEnvironment { get; set; }

[Inject, NotNull]
private DownloadService? DownloadService { get; set; }

private EmbedPDFTabBarMode _tabBarMode = EmbedPDFTabBarMode.Always;
private EmbedPDFTheme _theme = EmbedPDFTheme.System;
private EmbedPDFScrollStrategy _strategy = EmbedPDFScrollStrategy.Vertical;
private string _url = "./samples/sample.pdf";
Expand All @@ -29,27 +22,8 @@ public partial class EmbedPdfs
new SelectedItem("zh-CN", "zh-CN")
};

private async Task<Stream> OnGetStreamAsync()
{
await Task.Yield();
if (string.IsNullOrEmpty(_streamFileName))
{
return Stream.Null;
}

var stream = File.OpenRead(Path.Combine(WebHostEnvironment.WebRootPath, "samples", _streamFileName));
return stream;
}

private void GetTestStream()
{
_url = "";
_streamFileName = "ebook.pdf";
}

private void GetSampleStream()
private async Task OnSetUrl(string fileName)
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method OnSetUrl is marked as async but doesn't contain any await operations. This should be changed to a synchronous method by removing the async keyword and changing the return type from Task to void.

Suggested change
private async Task OnSetUrl(string fileName)
private void OnSetUrl(string fileName)

Copilot uses AI. Check for mistakes.
{
_url = "";
_streamFileName = "sample.pdf";
_url = $"./samples/{fileName}";
}
Comment on lines +25 to 28
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid async without await to remove the CS1998 compiler warning.

Since OnSetUrl doesn’t do any asynchronous work but likely needs to match a Func<Task> signature, keep the Task return type and remove async by implementing it as:

private Task OnSetUrl(string fileName)
{
    _url = $"./samples/{fileName}";
    return Task.CompletedTask;
}
Suggested change
private async Task OnSetUrl(string fileName)
{
_url = "";
_streamFileName = "sample.pdf";
_url = $"./samples/{fileName}";
}
private Task OnSetUrl(string fileName)
{
_url = $"./samples/{fileName}";
return Task.CompletedTask;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ void AddData(DemoMenuItem item)
},
new()
{
IsNew = true,
Text = Localizer["EmbedPdf"],
Url = "embed-pdf"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private static string GetFriendlyTypeName(Type type)

return type.Name switch
{
"UInt32" => "uint",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider handling other unsigned primitive aliases for consistency.

Specifically, consider also mapping UInt16"ushort", UInt64"ulong", and Byte"byte" (if not already handled) so all primitive numeric types use their keyword forms.

"Int32" => "int",
"String" => "string",
"Boolean" => "bool",
Expand Down
Loading