Blazor - Component expects a value for the parameter , but a value may not have been provided. When using EditorRequired.

Hi, I have problem with annoying warnings and underlining my code when component parameter is marked as required.:

Component 'TestComponent' expects a value for the parameter 'Test', but a value may not have been provided.

File TestComponent.razor:

@code { 

[Parameter, EditorRequired]
public RenderFragment? Test { get; set; }
}

<div>
@Test
</div>

File Index.razor:

<TestComponent>
<Test>
<div>test</div>
</Test>
</TestComponent>

Same code works with no warnings on VS 22.

 

0
8 comments

Hi PiotrX1

I couldn't reproduce it with the provided code in Rider versions 2022.2.3 and EAP3. What version do you use? Could you please add a solution itself? 

Thank you in advance! 

 

0

I have the same issue on Rider 2022.2.3, build RD-222.4167.23.

Solution: blazor-in-action/chapter-07/BlazingTrails at main · chrissainty/blazor-in-action (github.com)

Warning: "Component 'ViewSwitcher' expects a value for the parameter 'RowTemplate', but a value may not have been provided."

Warning in file: blazor-in-action/HomePage.razor at main · chrissainty/blazor-in-action (github.com)

0

Hello PiotrX1, JHodgins

Thank you for the projects. Please try the latest EAP. As I can see, the issue seems to be fixed there. 

Should you have any other questions, let me know. Thanks! 

0

From time to time I still have the issue in JetBrains Rider 2024.1.1. 'Invalidate Caches…' does not help.

0

Hi Dmitry Filippov, would you mind providing a minimal reproduction/sample solution of the issue so that we can investigate further? 

Please upload the file to our server and share the ID.

 

 

0

Hi Tao Sun, to be honest, I have no idea how to prepare a sample solution to reproduce the problem.

I can suggest to open our solution https://github.com/Actual-Chat/actual-chat/blob/release/v1.11/ActualChat.sln

See ChatListTabUnreadCount.razor. My colleague also have issue there, so apparently you will able to reproduce it as well.

0

Hi Dmitry Filippov , it could be a bug of the code analysis.

I have created a corresponding record on our bug tracker: 

RIDER-112336 False positive "Missed value for required attribute" inspection result for init only setter declared attribute.

The issue is handled by a dedicated developer there. Please upvote it and click Watch to monitor the progress of the issue.

A normal setter will not trigger the issue as same as using init only setters.

 

-1

Please sign in to leave a comment.