Skip to content

Commit 47eb534

Browse files
author
N. Taylor Mullen
committed
Update sample applications to use public [Parameter]s.
- Updated all `[Parameter]` references in .cs, .razor and .cshtml files to be `public`. #8825
1 parent fedf03b commit 47eb534

34 files changed

+120
-120
lines changed

src/Components/Blazor/Build/test/BindRazorIntegrationTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace Test
3131
public class MyComponent : ComponentBase
3232
{
3333
[Parameter]
34-
int Value { get; set; }
34+
public int Value { get; set; }
3535
3636
[Parameter]
37-
Action<int> ValueChanged { get; set; }
37+
public Action<int> ValueChanged { get; set; }
3838
}
3939
}"));
4040

@@ -105,10 +105,10 @@ namespace Test
105105
public class MyComponent : ComponentBase
106106
{
107107
[Parameter]
108-
int Value { get; set; }
108+
public int Value { get; set; }
109109
110110
[Parameter]
111-
Action<int> OnChanged { get; set; }
111+
public Action<int> OnChanged { get; set; }
112112
}
113113
}"));
114114

src/Components/Blazor/Build/test/ChildContentRazorIntegrationTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
2525
}
2626
2727
[Parameter]
28-
RenderFragment ChildContent { get; set; }
28+
public RenderFragment ChildContent { get; set; }
2929
}
3030
}
3131
");
@@ -43,10 +43,10 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
4343
}
4444
4545
[Parameter]
46-
RenderFragment<string> ChildContent { get; set; }
46+
public RenderFragment<string> ChildContent { get; set; }
4747
4848
[Parameter]
49-
string Value { get; set; }
49+
public string Value { get; set; }
5050
}
5151
}
5252
");
@@ -66,19 +66,19 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
6666
}
6767
6868
[Parameter]
69-
string Name { get; set; }
69+
public string Name { get; set; }
7070
7171
[Parameter]
72-
RenderFragment<string> Header { get; set; }
72+
public RenderFragment<string> Header { get; set; }
7373
7474
[Parameter]
75-
RenderFragment<string> ChildContent { get; set; }
75+
public RenderFragment<string> ChildContent { get; set; }
7676
7777
[Parameter]
78-
RenderFragment Footer { get; set; }
78+
public RenderFragment Footer { get; set; }
7979
8080
[Parameter]
81-
string Value { get; set; }
81+
public string Value { get; set; }
8282
}
8383
}
8484
");

src/Components/Blazor/Build/test/ComponentRenderingRazorIntegrationTest.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public class SomeType
6262
6363
public class MyComponent : ComponentBase
6464
{
65-
[Parameter] int IntProperty { get; set; }
66-
[Parameter] bool BoolProperty { get; set; }
67-
[Parameter] string StringProperty { get; set; }
68-
[Parameter] SomeType ObjectProperty { get; set; }
65+
[Parameter] public int IntProperty { get; set; }
66+
[Parameter] public bool BoolProperty { get; set; }
67+
[Parameter] public string StringProperty { get; set; }
68+
[Parameter] public SomeType ObjectProperty { get; set; }
6969
}
7070
}
7171
"));
@@ -135,7 +135,7 @@ namespace Test
135135
public class MyComponent : ComponentBase
136136
{
137137
[Parameter]
138-
string StringProperty { get; set; }
138+
public string StringProperty { get; set; }
139139
}
140140
}
141141
"));
@@ -208,7 +208,7 @@ namespace Test
208208
public class MyComponent : ComponentBase
209209
{
210210
[Parameter]
211-
Action<UIMouseEventArgs> OnClick { get; set; }
211+
public Action<UIMouseEventArgs> OnClick { get; set; }
212212
}
213213
}
214214
"));
@@ -253,7 +253,7 @@ namespace Test
253253
public class MyComponent : ComponentBase
254254
{
255255
[Parameter]
256-
Action<UIEventArgs> OnClick { get; set; }
256+
public Action<UIEventArgs> OnClick { get; set; }
257257
}
258258
}
259259
"));
@@ -298,7 +298,7 @@ namespace Test
298298
public class MyComponent : ComponentBase
299299
{
300300
[Parameter]
301-
bool BoolProperty { get; set; }
301+
public bool BoolProperty { get; set; }
302302
}
303303
}"));
304304

@@ -326,10 +326,10 @@ namespace Test
326326
public class MyComponent : ComponentBase
327327
{
328328
[Parameter]
329-
string MyAttr { get; set; }
329+
public string MyAttr { get; set; }
330330
331331
[Parameter]
332-
RenderFragment ChildContent { get; set; }
332+
public RenderFragment ChildContent { get; set; }
333333
}
334334
}
335335
"));
@@ -370,7 +370,7 @@ namespace Test
370370
public class MyComponent : ComponentBase
371371
{
372372
[Parameter]
373-
RenderFragment ChildContent { get; set; }
373+
public RenderFragment ChildContent { get; set; }
374374
}
375375
}
376376
"));
@@ -416,7 +416,7 @@ namespace Test
416416
{
417417
public class SurveyPrompt : ComponentBase
418418
{
419-
[Parameter] private string Title { get; set; }
419+
[Parameter] public string Title { get; set; }
420420
}
421421
}
422422
"));
@@ -508,7 +508,7 @@ namespace Test
508508
public class MyComponent : ComponentBase
509509
{
510510
[Parameter]
511-
RenderFragment ChildContent { get; set; }
511+
public RenderFragment ChildContent { get; set; }
512512
}
513513
}
514514
"));
@@ -571,9 +571,9 @@ namespace Test
571571
{
572572
public class Repeater : ComponentBase
573573
{
574-
[Parameter] int Count { get; set; }
575-
[Parameter] RenderFragment<string> Template { get; set; }
576-
[Parameter] string Value { get; set; }
574+
[Parameter] public int Count { get; set; }
575+
[Parameter] public RenderFragment<string> Template { get; set; }
576+
[Parameter] public string Value { get; set; }
577577
578578
protected override void BuildRenderTree(RenderTreeBuilder builder)
579579
{

src/Components/Blazor/Build/test/DirectiveRazorIntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void SupportsInjectDirective()
147147
public class TestLayout : IComponent
148148
{
149149
[Parameter]
150-
RenderFragment Body { get; set; }
150+
public RenderFragment Body { get; set; }
151151

152152
public void Configure(RenderHandle renderHandle)
153153
{

src/Components/Blazor/Build/test/GenericComponentRazorIntegrationTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
4141
}
4242
4343
[Parameter]
44-
List<TItem> Items { get; set; }
44+
public List<TItem> Items { get; set; }
4545
4646
[Parameter]
47-
RenderFragment<Context> ChildContent { get; set; }
47+
public RenderFragment<Context> ChildContent { get; set; }
4848
4949
public class Context
5050
{
@@ -70,13 +70,13 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
7070
}
7171
7272
[Parameter]
73-
TItem1 Item1 { get; set; }
73+
public TItem1 Item1 { get; set; }
7474
7575
[Parameter]
76-
TItem2 Item2 { get; set; }
76+
public TItem2 Item2 { get; set; }
7777
7878
[Parameter]
79-
TItem3 Item3 { get; set; }
79+
public TItem3 Item3 { get; set; }
8080
}
8181
}
8282
");
@@ -224,7 +224,7 @@ @typeparam TItem
224224
<GenericContext Items=""@MyItems"" @ref=""_my"" @ref:suppressField />
225225
226226
@code {
227-
[Parameter] List<TItem> MyItems { get; set; }
227+
[Parameter] public List<TItem> MyItems { get; set; }
228228
GenericContext<TItem> _my;
229229
void Foo() { GC.KeepAlive(_my); }
230230
}");

src/Components/Blazor/Templates/src/content/BlazorWasm-CSharp/Client/Shared/SurveyPrompt.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
@code {
1313
// Demonstrates how a parent component can supply parameters
14-
[Parameter] string Title { get; set; }
14+
[Parameter] public string Title { get; set; }
1515
}

src/Components/Blazor/testassets/StandaloneApp/Pages/FetchData.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ else
4444
}
4545

4646
@code {
47-
[Parameter] DateTime StartDate { get; set; }
47+
[Parameter] public DateTime StartDate { get; set; }
4848

4949
WeatherForecast[] forecasts;
5050

src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public abstract partial class LayoutComponentBase : Microsoft.AspNetCore.Compone
401401
{
402402
protected LayoutComponentBase() { }
403403
[Microsoft.AspNetCore.Components.ParameterAttribute]
404-
protected Microsoft.AspNetCore.Components.RenderFragment Body { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
404+
public Microsoft.AspNetCore.Components.RenderFragment Body { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
405405
}
406406
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
407407
public readonly partial struct MarkupString

src/Components/Components/src/LayoutComponentBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public abstract class LayoutComponentBase : ComponentBase
1616
/// Gets the content to be rendered inside the layout.
1717
/// </summary>
1818
[Parameter]
19-
protected RenderFragment Body { get; private set; }
19+
public RenderFragment Body { get; private set; }
2020
}
2121
}

src/Components/Components/test/Auth/AuthorizeViewTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
499499
// recurse into all descendants because we're passing ChildContent
500500
class NeverReRenderComponent : ComponentBase
501501
{
502-
[Parameter] RenderFragment ChildContent { get; set; }
502+
[Parameter] public RenderFragment ChildContent { get; set; }
503503

504504
protected override bool ShouldRender() => false;
505505

src/Components/Components/test/CascadingParameterStateTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,19 +389,19 @@ static CascadingValue<T> CreateCascadingValueComponent<T>(T value, string name =
389389
renderer.Dispatcher.InvokeAsync((Action)(() => supplier.SetParametersAsync(ParameterCollection.FromDictionary(supplierParams))));
390390
return supplier;
391391
}
392-
392+
393393
class ComponentWithNoParams : TestComponentBase
394394
{
395395
}
396396

397397
class ComponentWithNoCascadingParams : TestComponentBase
398398
{
399-
[Parameter] bool SomeRegularParameter { get; set; }
399+
[Parameter] public bool SomeRegularParameter { get; set; }
400400
}
401401

402402
class ComponentWithCascadingParams : TestComponentBase
403403
{
404-
[Parameter] bool RegularParam { get; set; }
404+
[Parameter] public bool RegularParam { get; set; }
405405
[CascadingParameter] internal ValueType1 CascadingParam1 { get; set; }
406406
[CascadingParameter] internal ValueType2 CascadingParam2 { get; set; }
407407
}

src/Components/Components/test/CascadingParameterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class CascadingParameterConsumerComponent<T> : AutoRenderComponent
381381
public int NumRenders { get; private set; }
382382

383383
[CascadingParameter] T CascadingParameter { get; set; }
384-
[Parameter] string RegularParameter { get; set; }
384+
[Parameter] public string RegularParameter { get; set; }
385385

386386
public override async Task SetParametersAsync(ParameterCollection parameters)
387387
{

src/Components/Components/test/PageDisplayTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void CanChangeDisplayedPageWithDifferentLayout()
220220
private class RootLayout : AutoRenderComponent
221221
{
222222
[Parameter]
223-
RenderFragment Body { get; set; }
223+
public RenderFragment Body { get; set; }
224224

225225
protected override void BuildRenderTree(RenderTreeBuilder builder)
226226
{
@@ -234,7 +234,7 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
234234
private class NestedLayout : AutoRenderComponent
235235
{
236236
[Parameter]
237-
RenderFragment Body { get; set; }
237+
public RenderFragment Body { get; set; }
238238

239239
protected override void BuildRenderTree(RenderTreeBuilder builder)
240240
{

src/Components/Components/test/ParameterCollectionAssignmentExtensionsTest.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ class HasInstanceProperties
364364
// "internal" to show we're not requiring public accessors, but also
365365
// to keep the assertions simple in the tests
366366

367-
[Parameter] internal int IntProp { get; set; }
368-
[Parameter] internal string StringProp { get; set; }
367+
[Parameter] public int IntProp { get; set; }
368+
[Parameter] public string StringProp { get; set; }
369369

370370
// Also a truly private one to show there's nothing special about 'internal'
371-
[Parameter] private object ObjectProp { get; set; }
371+
[Parameter] public object ObjectProp { get; set; }
372372

373373
public static string ObjectPropName => nameof(ObjectProp);
374374
public object ObjectPropCurrentValue
@@ -386,7 +386,7 @@ class HasPropertyWithoutParameterAttribute
386386
class HasPropertyWhoseSetterThrows
387387
{
388388
[Parameter]
389-
internal string StringProp
389+
public string StringProp
390390
{
391391
get => string.Empty;
392392
set => throw new InvalidOperationException("This setter throws");
@@ -395,37 +395,37 @@ internal string StringProp
395395

396396
class HasInheritedProperties : HasInstanceProperties
397397
{
398-
[Parameter] internal int DerivedClassIntProp { get; set; }
398+
[Parameter] public int DerivedClassIntProp { get; set; }
399399
}
400400

401401
class HasParametersVaryingOnlyByCase
402402
{
403-
[Parameter] internal object MyValue { get; set; }
404-
[Parameter] internal object Myvalue { get; set; }
403+
[Parameter] public object MyValue { get; set; }
404+
[Parameter] public object Myvalue { get; set; }
405405
}
406406

407407
class HasParameterClashingWithInherited : HasInstanceProperties
408408
{
409-
[Parameter] new int IntProp { get; set; }
409+
[Parameter] public new int IntProp { get; set; }
410410
}
411411

412412
class HasCaptureUnmatchedValuesProperty
413413
{
414-
[Parameter] internal int IntProp { get; set; }
415-
[Parameter] internal string StringProp { get; set; }
416-
[Parameter] internal object ObjectProp { get; set; }
417-
[Parameter(CaptureUnmatchedValues = true)] internal IReadOnlyDictionary<string, object> CaptureUnmatchedValues { get; set; }
414+
[Parameter] public int IntProp { get; set; }
415+
[Parameter] public string StringProp { get; set; }
416+
[Parameter] public object ObjectProp { get; set; }
417+
[Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary<string, object> CaptureUnmatchedValues { get; set; }
418418
}
419419

420420
class HasDupliateCaptureUnmatchedValuesProperty
421421
{
422-
[Parameter(CaptureUnmatchedValues = true)] internal Dictionary<string, object> CaptureUnmatchedValuesProp1 { get; set; }
423-
[Parameter(CaptureUnmatchedValues = true)] internal IDictionary<string, object> CaptureUnmatchedValuesProp2 { get; set; }
422+
[Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> CaptureUnmatchedValuesProp1 { get; set; }
423+
[Parameter(CaptureUnmatchedValues = true)] public IDictionary<string, object> CaptureUnmatchedValuesProp2 { get; set; }
424424
}
425425

426426
class HasWrongTypeCaptureUnmatchedValuesProperty
427427
{
428-
[Parameter(CaptureUnmatchedValues = true)] internal KeyValuePair<string, object>[] CaptureUnmatchedValuesProp { get; set; }
428+
[Parameter(CaptureUnmatchedValues = true)] public KeyValuePair<string, object>[] CaptureUnmatchedValuesProp { get; set; }
429429
}
430430

431431
class ParameterCollectionBuilder : IEnumerable

0 commit comments

Comments
 (0)