@@ -274,6 +274,46 @@ public static class RuntimeHelpers
274
274
Assert . DoesNotContain ( "AddComponentParameter" , source . SourceText . ToString ( ) ) ;
275
275
}
276
276
277
+ [ Fact ]
278
+ public async Task ComponentParameter_UnnecessaryAt ( )
279
+ {
280
+ // Arrange
281
+ var project = CreateTestProject ( new ( )
282
+ {
283
+ [ "Views/Home/Index.cshtml" ] = """
284
+ @(await Html.RenderComponentAsync<MyApp.Shared.Component1>(RenderMode.Static))
285
+ """ ,
286
+ [ "Shared/Component1.razor" ] = """
287
+ @{
288
+ var hi = "str";
289
+ var x = 21;
290
+ }
291
+ <Component2 IntParam="42" StrParam="hi" />
292
+ <Component2 IntParam="@(43)" StrParam="@hi" />
293
+ <Component2 IntParam="@x" StrParam="@("lit")" />
294
+ <Component2 IntParam="x * 3" StrParam="@(hi + "hey")" />
295
+ """ ,
296
+ [ "Shared/Component2.razor" ] = """
297
+ I: @(IntParam + 1), S: @StrParam.ToUpperInvariant()
298
+
299
+ @code {
300
+ [Parameter] public int IntParam { get; set; }
301
+ [Parameter] public required string StrParam { get; set; }
302
+ }
303
+ """
304
+ } ) ;
305
+ var compilation = await project . GetCompilationAsync ( ) ;
306
+ var driver = await GetDriverAsync ( project ) ;
307
+
308
+ // Act
309
+ var result = RunGenerator ( compilation ! , ref driver , out compilation ) ;
310
+
311
+ // Assert
312
+ Assert . Empty ( result . Diagnostics ) ;
313
+ Assert . Equal ( 3 , result . GeneratedSources . Length ) ;
314
+ await VerifyRazorPageMatchesBaselineAsync ( compilation , "Views_Home_Index" ) ;
315
+ }
316
+
277
317
[ Fact , WorkItem ( "https://github.com/dotnet/razor/issues/8660" ) ]
278
318
public async Task TypeArgumentsCannotBeInferred ( )
279
319
{
0 commit comments