-
-
Notifications
You must be signed in to change notification settings - Fork 375
feat(EmbedPDF): add EmbedPDF component #7572
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the EmbedPdfs demo to use the new EmbedPDF component via URL-based loading, simplifies the sample UI, and improves supporting infrastructure (menu metadata and attribute type name mapping) for the new component. Sequence diagram for switching PDFs in the EmbedPdfs demosequenceDiagram
actor User
participant Browser
participant EmbedPdfs
participant EmbedPDF
User->>Browser: Click Sample.Pdf button
Browser->>EmbedPdfs: Invoke OnSetUrl("sample.pdf")
activate EmbedPdfs
EmbedPdfs->>EmbedPdfs: _url = "./samples/sample.pdf"
deactivate EmbedPdfs
EmbedPdfs-->>Browser: Component state updated
Browser->>Browser: Re-render component tree
Browser->>EmbedPDF: Render with Url = _url
EmbedPDF-->>User: Display sample.pdf in viewer
User->>Browser: Click EBook.Pdf button
Browser->>EmbedPdfs: Invoke OnSetUrl("ebook.pdf")
activate EmbedPdfs
EmbedPdfs->>EmbedPdfs: _url = "./samples/ebook.pdf"
deactivate EmbedPdfs
EmbedPdfs-->>Browser: Component state updated
Browser->>Browser: Re-render component tree
Browser->>EmbedPDF: Render with Url = _url
EmbedPDF-->>User: Display ebook.pdf in viewer
Class diagram for EmbedPdfs and ComponentAttributeCacheService changesclassDiagram
class EmbedPdfs {
-EmbedPDFTheme _theme
-EmbedPDFScrollStrategy _strategy
-string _url
-string _streamFileName
-string _language
-IEnumerable~SelectedItem~ _languages
+Task OnSetUrl(string fileName)
}
class ComponentAttributeCacheService {
-static string GetFriendlyTypeName(Type type)
}
class Type {
+string Name
}
EmbedPdfs ..> EmbedPDFTheme
EmbedPdfs ..> EmbedPDFScrollStrategy
EmbedPdfs ..> SelectedItem
ComponentAttributeCacheService ..> Type
class EmbedPDFTheme
class EmbedPDFScrollStrategy
class SelectedItem {
+SelectedItem(string value)
+SelectedItem(string value, string text)
}
class EmbedPDF {
+string Url
+string ViewHeight
+string Language
+EmbedPDFTheme Theme
+EmbedPDFScrollStrategy ScrollStrategy
}
EmbedPdfs ..> EmbedPDF
class DemoMenuItem {
+bool IsNew
+string Text
+string Url
}
ComponentAttributeCacheService : GetFriendlyTypeName maps "UInt32" -> "uint"
ComponentAttributeCacheService : GetFriendlyTypeName maps "Int32" -> "int"
ComponentAttributeCacheService : GetFriendlyTypeName maps "String" -> "string"
ComponentAttributeCacheService : GetFriendlyTypeName maps "Boolean" -> "bool"
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 2 issues, and left some high level feedback:
- The new
OnSetUrlmethod is markedasyncbut never awaited, so it can be made synchronous (voidorTaskwithoutasync) to avoid compiler warnings and unnecessary state machine generation. - With the switch from stream-based loading to URL-based loading for PDFs, double-check that any now-unused fields (e.g.,
_streamFileName) or services (DownloadService,IWebHostEnvironment) are fully removed from the partial class to keep the sample component lean.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `OnSetUrl` method is marked `async` but never awaited, so it can be made synchronous (`void` or `Task` without `async`) to avoid compiler warnings and unnecessary state machine generation.
- With the switch from stream-based loading to URL-based loading for PDFs, double-check that any now-unused fields (e.g., `_streamFileName`) or services (`DownloadService`, `IWebHostEnvironment`) are fully removed from the partial class to keep the sample component lean.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs:25-28` </location>
<code_context>
- }
-
- private void GetSampleStream()
+ private async Task OnSetUrl(string fileName)
{
- _url = "";
- _streamFileName = "sample.pdf";
+ _url = $"./samples/{fileName}";
}
}
</code_context>
<issue_to_address>
**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:
```csharp
private Task OnSetUrl(string fileName)
{
_url = $"./samples/{fileName}";
return Task.CompletedTask;
}
```
```suggestion
private Task OnSetUrl(string fileName)
{
_url = $"./samples/{fileName}";
return Task.CompletedTask;
}
```
</issue_to_address>
### Comment 2
<location> `src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs:149` </location>
<code_context>
return type.Name switch
{
+ "UInt32" => "uint",
"Int32" => "int",
"String" => "string",
</code_context>
<issue_to_address>
**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.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| private async Task OnSetUrl(string fileName) | ||
| { | ||
| _url = ""; | ||
| _streamFileName = "sample.pdf"; | ||
| _url = $"./samples/{fileName}"; | ||
| } |
There was a problem hiding this comment.
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;
}| private async Task OnSetUrl(string fileName) | |
| { | |
| _url = ""; | |
| _streamFileName = "sample.pdf"; | |
| _url = $"./samples/{fileName}"; | |
| } | |
| private Task OnSetUrl(string fileName) | |
| { | |
| _url = $"./samples/{fileName}"; | |
| return Task.CompletedTask; | |
| } |
|
|
||
| return type.Name switch | ||
| { | ||
| "UInt32" => "uint", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds the EmbedPDF component to the demo server by updating the package from beta to stable version, refactoring the demo page to simplify the interface, and adding proper type mapping support for component attributes.
Changes:
- Updated BootstrapBlazor.EmbedPDF package from version 10.0.0-beta04 to 10.0.0 (stable release)
- Simplified the EmbedPDF demo by removing stream-based PDF loading and TabBarMode configuration
- Added UInt32 type mapping in ComponentAttributeCacheService for better type display
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/BootstrapBlazor.Server/Services/ComponentAttributeCacheService.cs | Adds UInt32 to uint type mapping for friendly display in component attribute tables |
| src/BootstrapBlazor.Server/Extensions/MenusLocalizerExtensions.cs | Marks the EmbedPdf menu item as new with IsNew flag |
| src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor.cs | Refactors code-behind by removing unused stream handling and simplifying URL switching |
| src/BootstrapBlazor.Server/Components/Samples/EmbedPdfs.razor | Updates UI by removing TabBarMode controls and adding buttons to switch between sample PDFs |
| src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj | Updates EmbedPDF package from beta04 to stable 10.0.0 version |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| private void GetSampleStream() | ||
| private async Task OnSetUrl(string fileName) |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| private async Task OnSetUrl(string fileName) | |
| private void OnSetUrl(string fileName) |
Link issues
fixes #7571
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Simplify the EmbedPDF sample page and surface the new component in the demo navigation and attribute metadata.
New Features:
Enhancements: