From 8ed173d18591c1f4b40caeae54f0f2b6564435e6 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 15:41:09 +0200 Subject: [PATCH 01/28] Upgrade projects to .NET 6 --- .../FluentUIServerSample/FluentUIServerSample.csproj | 2 +- .../Microsoft.Fast.Components.FluentUI.csproj | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/FluentUIServerSample/FluentUIServerSample.csproj b/examples/FluentUIServerSample/FluentUIServerSample.csproj index 900d4a3954..1edfae927f 100644 --- a/examples/FluentUIServerSample/FluentUIServerSample.csproj +++ b/examples/FluentUIServerSample/FluentUIServerSample.csproj @@ -5,7 +5,7 @@ - net5.0 + net6.0 diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 989fb56206..7d4f7c59d4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -1,8 +1,8 @@  - net5.0 - Microsoft.Fast.Components.FluentUI + net6.0 + Microsoft.Fast.Components.FluentUI Microsoft © Microsoft Corporation. All rights reserved. en @@ -10,7 +10,7 @@ https://github.com/microsoft/fast-blazor MIT Fluent UI Web Components library for Blazor on .NET - Web Components, .NET, FluentUI, FAST, Blazor, .NET 5.0 + Web Components, .NET, FluentUI, FAST, Blazor, .NET 6.0 Microsoft Fluent UI Components Library for Blazor on FAST Authored by the Microsoft FAST team. true @@ -24,7 +24,7 @@ 4 true false - bin\Debug\net5.0\Microsoft.Fast.Components.FluentUI.xml + bin\Debug\net6.0\Microsoft.Fast.Components.FluentUI.xml 1701;1702,8669,1591 @@ -32,7 +32,7 @@ - + From 3f5766fc9c628d2c36e8798bc16ff7130ad50539 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 15:50:23 +0200 Subject: [PATCH 02/28] Enable nullable for sample project --- .../Components/FluentDialogTest.razor | 6 +++--- .../FluentUIServerSample.csproj | 3 ++- .../Pages/ComponentBindings.razor | 10 ++++----- .../Pages/Error.cshtml.cs | 10 +++------ .../Pages/RawBindings.razor | 21 +++++++++---------- .../Pages/Webcomponents.razor | 2 +- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/examples/FluentUIServerSample/Components/FluentDialogTest.razor b/examples/FluentUIServerSample/Components/FluentDialogTest.razor index 4188a7237b..299b17fed6 100644 --- a/examples/FluentUIServerSample/Components/FluentDialogTest.razor +++ b/examples/FluentUIServerSample/Components/FluentDialogTest.razor @@ -15,12 +15,12 @@ @code{ - private FluentDialog MyFluentDialog; + private FluentDialog? MyFluentDialog; public bool ModalHidden { get; set; } = true; - private void OnOpenModalRefButtonClick() => MyFluentDialog.Show(); - private void OnCloseModalRefButtonClick() => MyFluentDialog.Hide(); + private void OnOpenModalRefButtonClick() => MyFluentDialog!.Show(); + private void OnCloseModalRefButtonClick() => MyFluentDialog!.Hide(); private void OnOpenModalParameterButtonClick() => ModalHidden = false; private void OnCloseModalParameterButtonClick() => ModalHidden = true; diff --git a/examples/FluentUIServerSample/FluentUIServerSample.csproj b/examples/FluentUIServerSample/FluentUIServerSample.csproj index 1edfae927f..f03c13a521 100644 --- a/examples/FluentUIServerSample/FluentUIServerSample.csproj +++ b/examples/FluentUIServerSample/FluentUIServerSample.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ net6.0 + enable diff --git a/examples/FluentUIServerSample/Pages/ComponentBindings.razor b/examples/FluentUIServerSample/Pages/ComponentBindings.razor index 9b5259088e..88b4d3c102 100644 --- a/examples/FluentUIServerSample/Pages/ComponentBindings.razor +++ b/examples/FluentUIServerSample/Pages/ComponentBindings.razor @@ -158,22 +158,22 @@ private class FormModel { [Required] - public string SelectValue { get; set; } + public string? SelectValue { get; set; } [Required] - public string TextFieldValue { get; set; } + public string? TextFieldValue { get; set; } [Required] public int? NumberFieldValue { get; set; } [Required] - public string TextAreaValue { get; set; } + public string? TextAreaValue { get; set; } [Required] - public string ComboboxValue { get; set; } + public string? ComboboxValue { get; set; } [Required] - public string RadioGroupValue { get; set; } + public string? RadioGroupValue { get; set; } [Required] public bool CheckboxValue { get; set; } diff --git a/examples/FluentUIServerSample/Pages/Error.cshtml.cs b/examples/FluentUIServerSample/Pages/Error.cshtml.cs index cd304bb09e..f13f59953b 100644 --- a/examples/FluentUIServerSample/Pages/Error.cshtml.cs +++ b/examples/FluentUIServerSample/Pages/Error.cshtml.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using System.Diagnostics; namespace FluentUIServerSample.Pages { @@ -13,7 +9,7 @@ namespace FluentUIServerSample.Pages [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - public string RequestId { get; set; } + public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); diff --git a/examples/FluentUIServerSample/Pages/RawBindings.razor b/examples/FluentUIServerSample/Pages/RawBindings.razor index f631fbeb95..468002831e 100644 --- a/examples/FluentUIServerSample/Pages/RawBindings.razor +++ b/examples/FluentUIServerSample/Pages/RawBindings.razor @@ -121,12 +121,12 @@ @code { - string TextFieldValueImplicit; - string TextFieldValueExplicit; + string? TextFieldValueImplicit; + string? TextFieldValueExplicit; int NumberFieldValueImplicit; int NumberFieldValueExplicit; - string TextAreaValueImplicit; - string TextAreaValueExplicit; + string? TextAreaValueImplicit; + string? TextAreaValueExplicit; bool CheckboxValueImplicit; bool CheckboxValueExplicit; bool SwitchValueImplicit; @@ -135,13 +135,12 @@ bool FluentMenuItemValueExplicit; int SliderValueImplicit; int SliderValueExplicit; - string SelectValueImplicit; - string SelectValueExplicit; - string RadioGroupValueImplicit; - string RadioGroupValueExplicit; + string? SelectValueImplicit; + string? SelectValueExplicit; + string? RadioGroupValueImplicit; + string? RadioGroupValueExplicit; int ListboxIndexValueImplicit; int ListboxIndexValueExplicit; - string ComboboxValueImplicit; - string ComboboxValueExplicit; - + string? ComboboxValueImplicit; + string? ComboboxValueExplicit; } diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 1adf1db308..3d5b36904d 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -253,5 +253,5 @@ @code{ - [Parameter] public string Target { get; set; } = null; + [Parameter] public string? Target { get; set; } = null; } \ No newline at end of file From e9c0f7426d072bf7a17b65f84f7f16b87abaa94d Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 16:06:23 +0200 Subject: [PATCH 03/28] Enable Nullable for component project (excluded that changes related to change inheritance to InputBase) --- src/Microsoft.Fast.Components.FluentUI/Appearance.cs | 6 ++---- src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs | 8 ++++---- src/Microsoft.Fast.Components.FluentUI/Color.cs | 8 ++++---- .../Components/FluentAccordion.razor | 4 ++-- .../Components/FluentAccordionItem.razor | 4 ++-- .../Components/FluentAnchor.razor | 6 +++--- .../Components/FluentBadge.razor | 4 ++-- .../Components/FluentBreadcrumb.razor | 4 ++-- .../Components/FluentBreadcrumbItem.razor | 6 +++--- .../Components/FluentButton.razor | 4 ++-- .../Components/FluentCard.razor | 4 ++-- .../Components/FluentCheckbox.razor | 4 ++-- .../Components/FluentCombobox.razor | 2 +- .../Components/FluentDialog.razor | 4 ++-- .../Components/FluentDivider.razor | 4 ++-- .../Components/FluentFlipper.razor | 4 ++-- .../Components/FluentListbox.razor | 4 ++-- .../Components/FluentMenu.razor | 4 ++-- .../Components/FluentMenuItem.razor | 4 ++-- .../Components/FluentNumberField.razor | 10 +++++----- .../Components/FluentOption.razor | 6 +++--- .../Components/FluentProgress.razor | 4 ++-- .../Components/FluentProgressRing.razor | 4 ++-- .../Components/FluentRadio.razor | 6 +++--- .../Components/FluentRadioGroup.razor | 4 ++-- .../Components/FluentSelect.razor | 4 ++-- .../Components/FluentSkeleton.razor | 6 +++--- .../Components/FluentSlider.razor | 4 ++-- .../Components/FluentSliderLabel.razor | 4 ++-- .../Components/FluentSwitch.razor | 4 ++-- .../Components/FluentTab.razor | 4 ++-- .../Components/FluentTabPanel.razor | 4 ++-- .../Components/FluentTabs.razor | 4 ++-- .../Components/FluentTextArea.razor | 4 ++-- .../Components/FluentTextField.razor | 4 ++-- .../Components/FluentTreeItem.razor | 4 ++-- .../Components/FluentTreeView.razor | 4 ++-- .../Components/NavLinkFluentAnchor.cs | 8 ++------ src/Microsoft.Fast.Components.FluentUI/Direction.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs | 4 ++-- .../Microsoft.Fast.Components.FluentUI.csproj | 1 + src/Microsoft.Fast.Components.FluentUI/Orientation.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/Resize.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/Shape.cs | 4 ++-- .../TextFieldType.cs | 6 ++---- 45 files changed, 100 insertions(+), 107 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs index c62398311f..1b3ffe1f0c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Fast.Components.FluentUI { @@ -20,8 +18,8 @@ public enum Appearance internal static class AppearanceExtensions { private static Dictionary _appearanceValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Appearance? value) => value == null ? null : _appearanceValues[value.Value]; + public static string? ToAttributeValue(this Appearance? value) => value == null ? null : _appearanceValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs index 42cf879418..60ba4e83b5 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs @@ -14,9 +14,9 @@ public enum Autocomplete internal static class AutocompleteExtensions { private static Dictionary _autocompleteValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Autocomplete? value) => value == null ? null : _autocompleteValues[value.Value]; + public static string? ToAttributeValue(this Autocomplete? value) => value == null ? null : _autocompleteValues[value.Value]; } public enum Position @@ -28,8 +28,8 @@ public enum Position internal static class PositionExtensions { private static Dictionary _positionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Position? value) => value == null ? null : _positionValues[value.Value]; + public static string? ToAttributeValue(this Position? value) => value == null ? null : _positionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Color.cs b/src/Microsoft.Fast.Components.FluentUI/Color.cs index 243da3600e..4ea51e596f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Color.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Color.cs @@ -13,9 +13,9 @@ public enum Color internal static class ColorExtensions { private static Dictionary _colorValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Color? value) => value == null ? null : _colorValues[value.Value]; + public static string? ToAttributeValue(this Color? value) => value == null ? null : _colorValues[value.Value]; } public enum Fill @@ -27,8 +27,8 @@ public enum Fill internal static class FillExtensions { private static Dictionary _fillValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Fill? value) => value == null ? null : _fillValues[value.Value]; + public static string? ToAttributeValue(this Fill? value) => value == null ? null : _fillValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor index ab2eaab376..6eb43f03e9 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public ExpandMode? ExpandMode { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor index c08d3efd8d..68bb0eab33 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? Expanded { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor index 4966e472df..45817f2c60 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor @@ -1,11 +1,11 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor index c9abdcd575..c26f7515d4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor @@ -7,7 +7,7 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor index 63272960f1..47a66f6997 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor index c4fee0db5d..4af1f80142 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor @@ -1,9 +1,9 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor index e4e2457939..1ea1583b75 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor @@ -7,7 +7,7 @@ [Parameter] public bool? Autofocus { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor index bddcba0796..0ba27dc22d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor index 74f0ad4b2b..4f96369362 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor @@ -3,13 +3,13 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } [Parameter] public bool? Disabled { get; set; } [Parameter] public bool? Required { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out bool result, out string validationErrorMessage) => throw new NotSupportedException($"This component does not parse string inputs. Bind to the '{nameof(CurrentValue)}' property, not '{nameof(CurrentValueAsString)}'."); diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor index b33aac87fd..51083aa8c3 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor @@ -10,7 +10,7 @@ [Parameter] public Position? Position { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor index e60a603e67..727156733e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor @@ -3,9 +3,9 @@ { [Parameter] public bool? Modal { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } [Parameter] public bool Hidden { get; set; } = false; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor index 81210f4162..f318d3fb26 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor @@ -1,7 +1,7 @@ @ChildContent @code { - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor index bdeee2cb2f..8caa7667a2 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor @@ -5,7 +5,7 @@ [Parameter] public Direction? Direction { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor index 4d0e448577..ac1e9415f6 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor @@ -1,7 +1,7 @@ @ChildContent @code { - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor index 4cf878fa1c..1f873a9c29 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor index b4d8df9c38..06b223eb69 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor @@ -4,7 +4,7 @@ [Parameter] public bool? Checked { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor index d6154c6e84..b0573c3af3 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor @@ -34,14 +34,14 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } [Parameter] public string ParsingErrorMessage { get; set; } = "The {0} field must be a number."; - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter] public string Min { get; set; } = GetMinOrMaxValue("MinValue"); - [Parameter] public string Max { get; set; } = GetMinOrMaxValue("MaxValue"); + [Parameter] public string? Min { get; set; } = GetMinOrMaxValue("MinValue"); + [Parameter] public string? Max { get; set; } = GetMinOrMaxValue("MaxValue"); [Parameter] public int MinLength { get; set; } = 1; [Parameter] public int MaxLength { get; set; } = 14; [Parameter] public int Step { get; set; } = _stepAttributeValue; @@ -119,7 +119,7 @@ } } - private static string GetMinOrMaxValue(string name) + private static string? GetMinOrMaxValue(string name) { var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor index 39ea192485..11c932ca48 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor @@ -3,11 +3,11 @@ { [Parameter] public bool? Disabled { get; set; } - [Parameter] public string Value { get; set; } + [Parameter] public string? Value { get; set; } [Parameter] public bool? Selected { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor index 5ccc6a2484..24e37836be 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor @@ -8,7 +8,7 @@ [Parameter] public bool? Paused { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor index 078c912652..1a5fbc18c2 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor @@ -8,7 +8,7 @@ [Parameter] public bool? Paused { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor index 5f8af2db2a..3ba1221e7e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public string Value { get; set; } + [Parameter] public string? Value { get; set; } [Parameter] public bool? Required { get; set; } @@ -8,7 +8,7 @@ [Parameter] public bool? Checked { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor index acf51456f6..619cd43620 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor @@ -2,13 +2,13 @@ @ChildContent @code{ - [Parameter] public string Name { get; set; } + [Parameter] public string? Name { get; set; } [Parameter] public bool? Required { get; set; } [Parameter] public Orientation? Orientation { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor index 1f373fbb54..048b390760 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor @@ -5,11 +5,11 @@ [Parameter] public bool? Filled { get; set; } - [Parameter] public string Name { get; set; } + [Parameter] public string? Name { get; set; } [Parameter] public Position? Position { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor index 21ed0d8dc3..2413e91694 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor @@ -5,9 +5,9 @@ [Parameter] public bool? Shimmer { get; set; } - [Parameter] public string Pattern { get; set; } + [Parameter] public string? Pattern { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor index 0a6e582f25..7c14bf9952 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor @@ -15,7 +15,7 @@ [Parameter] public bool? Readonly { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out int result, out string validationErrorMessage) { @@ -31,7 +31,7 @@ } } - protected override string FormatValueAsString(int value) + protected override string? FormatValueAsString(int value) { return BindConverter.FormatValue(value, CultureInfo.InvariantCulture); } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor index 580e3f5d55..8f7e936db8 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor @@ -1,10 +1,10 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public int? Position { get; set; } [Parameter] public bool? HideMark { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor index 01f031bf62..1a0d7b0630 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor @@ -6,7 +6,7 @@ [Parameter] public bool? Required { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor index ef61a728d9..1aae0b3c94 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor index a8d86b84dc..a3460fec27 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor index 4aee601b48..0bb3be1a83 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor @@ -4,7 +4,7 @@ [Parameter] public Orientation? Orientation { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor index fc41500cb5..e06e6649e4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor @@ -13,9 +13,9 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor index 395d730566..a2178c112e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor @@ -30,7 +30,7 @@ [Parameter] public TextFieldType? TextFieldType { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } [Parameter] public int? MinLength { get; set; } @@ -41,7 +41,7 @@ //Pattern //List - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor index d350b6a8b5..1ebecfce9e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? Disabled { get; set; } @@ -8,5 +8,5 @@ [Parameter] public bool? Expanded { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor index 14df3beb27..8c6f9dcc8f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? RenderCollapsedNodes { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs b/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs index 79aa84b63a..ae301e066d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs @@ -1,16 +1,12 @@ - using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Rendering; using Microsoft.AspNetCore.Components.Routing; -using System; -using System.Collections.Generic; -using System.Linq; namespace Microsoft.Fast.Components.FluentUI { public class NavLinkFluentAnchor : NavLink - { - [Parameter] public string Href { get; set; } + { + [Parameter] public string? Href { get; set; } [Parameter] public Appearance? Appearance { get; set; } diff --git a/src/Microsoft.Fast.Components.FluentUI/Direction.cs b/src/Microsoft.Fast.Components.FluentUI/Direction.cs index 1a9e66c5f2..76cded635a 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Direction.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Direction.cs @@ -13,8 +13,8 @@ public enum Direction internal static class DirectionExtensions { private static Dictionary _directionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Direction? value) => value == null ? null : _directionValues[value.Value]; + public static string? ToAttributeValue(this Direction? value) => value == null ? null : _directionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs index fdef294b20..f339d2f8bd 100644 --- a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs +++ b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs @@ -12,8 +12,8 @@ public enum ExpandMode internal static class ExpandModeExtensions { private static Dictionary _expandModeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this ExpandMode? value) => value == null ? null : _expandModeValues[value.Value]; + public static string? ToAttributeValue(this ExpandMode? value) => value == null ? null : _expandModeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 7d4f7c59d4..190309e1a0 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -17,6 +17,7 @@ 0.3.0 0.3.0 false + enable diff --git a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs index 1e1f2eaf05..d0b22a1d31 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs @@ -12,8 +12,8 @@ public enum Orientation internal static class OrientationExtensions { private static Dictionary _orientationValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Orientation? value) => value == null ? null : _orientationValues[value.Value]; + public static string? ToAttributeValue(this Orientation? value) => value == null ? null : _orientationValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Resize.cs b/src/Microsoft.Fast.Components.FluentUI/Resize.cs index 56746bcdbf..1bb969303c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Resize.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Resize.cs @@ -14,8 +14,8 @@ public enum Resize internal static class ResizeExtensions { private static Dictionary _resizeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Resize? value) => value == null ? null : _resizeValues[value.Value]; + public static string? ToAttributeValue(this Resize? value) => value == null ? null : _resizeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Shape.cs b/src/Microsoft.Fast.Components.FluentUI/Shape.cs index 4d8917dfb3..be8e188807 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Shape.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Shape.cs @@ -13,8 +13,8 @@ public enum Shape internal static class ShapeExtensions { private static Dictionary _orientationValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Shape? value) => value == null ? null : _orientationValues[value.Value]; + public static string? ToAttributeValue(this Shape? value) => value == null ? null : _orientationValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs index dc73e34593..bf97038620 100644 --- a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs +++ b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Fast.Components.FluentUI { @@ -18,8 +16,8 @@ public enum TextFieldType internal static class TextFieldTypeExtensions { private static Dictionary _textFieldTypeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this TextFieldType? value) => value == null ? null : _textFieldTypeValues[value.Value]; + public static string? ToAttributeValue(this TextFieldType? value) => value == null ? null : _textFieldTypeValues[value.Value]; } } From 79cdfb1cfcd7ed2df55996765a7817774582e3ae Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 10:47:45 +0200 Subject: [PATCH 04/28] Enable Nullable for FluentInputBase derivates --- .../Components/FluentCheckbox.razor | 10 +- .../Components/FluentCombobox.razor | 13 +- .../Components/FluentNumberField.razor | 53 ++--- .../Components/FluentRadioGroup.razor | 4 +- .../Components/FluentSelect.razor | 16 +- .../Components/FluentSlider.razor | 14 +- .../Components/FluentTextArea.razor | 17 +- .../Components/FluentTextField.razor | 6 +- .../Components/_Imports.razor | 1 + .../FluentInputBase.cs | 213 ++++++++++++------ 10 files changed, 231 insertions(+), 116 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor index 4f96369362..fd4b530553 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor @@ -1,6 +1,12 @@ @inherits FluentInputBase @using System.Globalization -@ChildContent + + @ChildContent + @code { [Parameter] public string? Href { get; set; } @@ -11,6 +17,6 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out bool result, out string validationErrorMessage) => + protected override bool TryParseValueFromString(string? value, out bool result, [NotNullWhen(false)] out string? validationErrorMessage) => throw new NotSupportedException($"This component does not parse string inputs. Bind to the '{nameof(CurrentValue)}' property, not '{nameof(CurrentValueAsString)}'."); } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor index 51083aa8c3..b1d92d37b4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor @@ -1,5 +1,12 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code { [Parameter] public bool? Filled { get; set; } @@ -12,7 +19,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor index b0573c3af3..ac766884ee 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor @@ -1,4 +1,4 @@ -@inherits FluentInputBase +@inherits FluentInputBase @typeparam TValue @using System.Globalization; @using System.Reflection; @@ -12,7 +12,7 @@ maxlength="@MaxLength" minlength="@MinLength" size="@Size" - change="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" + change="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" readonly="@Readonly" disabled="@Disabled" required="@Required" @@ -69,7 +69,7 @@ } } - protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out TValue? result, [NotNullWhen(false)] out string? validationErrorMessage) { if (BindConverter.TryConvertTo(value, CultureInfo.InvariantCulture, out result)) { @@ -123,7 +123,7 @@ { var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); - FieldInfo field = targetType.GetField(name, BindingFlags.Public | BindingFlags.Static); + FieldInfo? field = targetType.GetField(name, BindingFlags.Public | BindingFlags.Static); if (field == null) { throw new InvalidOperationException("Invalid type argument for FluentNumberField: " + typeof(TValue).Name); @@ -131,30 +131,31 @@ var value = field.GetValue(null); - - if (targetType == typeof(int) || targetType == typeof(short)) - { - return value.ToString(); - } - - if (targetType == typeof(long)) - { - //Precision in underlying Fast script is limited to 12 digits - return name == "MinValue" ? "-999999999999" : "999999999999"; - } - if (targetType == typeof(float)) + if (value is not null) { - return ((float)value).ToString(CultureInfo.InvariantCulture); + if (targetType == typeof(int) || targetType == typeof(short)) + { + return value.ToString(); + } + + if (targetType == typeof(long)) + { + //Precision in underlying Fast script is limited to 12 digits + return name == "MinValue" ? "-999999999999" : "999999999999"; + } + if (targetType == typeof(float)) + { + return ((float)value).ToString(CultureInfo.InvariantCulture); + } + if (targetType == typeof(double)) + { + return ((double)value).ToString(CultureInfo.InvariantCulture); + } + if (targetType == typeof(decimal)) + { + return ((decimal)value).ToString("G12", CultureInfo.InvariantCulture); + } } - if (targetType == typeof(double)) - { - return ((double)value).ToString(CultureInfo.InvariantCulture); - } - if (targetType == typeof(decimal)) - { - return ((decimal)value).ToString("G12", CultureInfo.InvariantCulture); - } - // This should never occur return "0"; } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor index 619cd43620..96514adc58 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor @@ -1,4 +1,4 @@ -@inherits FluentInputBase +@inherits FluentInputBase @ChildContent @code{ @@ -10,7 +10,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor index 048b390760..e6fd03059f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor @@ -1,17 +1,25 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code{ [Parameter] public bool? Disabled { get; set; } [Parameter] public bool? Filled { get; set; } [Parameter] public string? Name { get; set; } - + [Parameter] public Position? Position { get; set; } [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor index 7c14bf9952..839d9d1304 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor @@ -1,6 +1,16 @@ @inherits FluentInputBase @using System.Globalization -@ChildContent + + @ChildContent + @code{ [Parameter] public Orientation? Orientation { get; set; } @@ -17,7 +27,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out int result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out int result, [NotNullWhen(false)] out string? validationErrorMessage) { if (BindConverter.TryConvertTo(value, CultureInfo.InvariantCulture, out result)) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor index e06e6649e4..6bd611374c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor @@ -1,5 +1,16 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code{ [Parameter] public bool? Disabled { get; set; } @@ -17,7 +28,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor index a2178c112e..b58a2e9dac 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor @@ -1,8 +1,8 @@ -@inherits FluentInputBase +@inherits FluentInputBase : ComponentBase, IDisposable { private readonly EventHandler _validationStateChangedHandler; + private bool _hasInitializedParameters; private bool _previousParsingAttemptFailed; - private ValidationMessageStore _parsingValidationMessages; - private Type _nullableUnderlyingType; - - [CascadingParameter] EditContext CascadedEditContext { get; set; } - - [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary AdditionalAttributes { get; set; } - + private ValidationMessageStore? _parsingValidationMessages; + private Type? _nullableUnderlyingType; + + [CascadingParameter] private EditContext? CascadedEditContext { get; set; } + + /// + /// Gets or sets a collection of additional attributes that will be applied to the created element. + /// + [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary? AdditionalAttributes { get; set; } + + /// + /// Gets or sets the value of the input. This should be used with two-way binding. + /// + /// + /// @bind-Value="model.PropertyName" + /// [Parameter] - public TValue Value { get; set; } + public TValue? Value { get; set; } + /// + /// Gets or sets a callback that updates the bound value. + /// [Parameter] public EventCallback ValueChanged { get; set; } - [Parameter] public Expression> ValueExpression { get; set; } - - [Parameter] public string DisplayName { get; set; } - - protected EditContext EditContext { get; set; } - + /// + /// Gets or sets an expression that identifies the bound value. + /// + [Parameter] public Expression>? ValueExpression { get; set; } + + /// + /// Gets or sets the display name for this field. + /// This value is used when generating error messages when the input value fails to parse correctly. + /// + [Parameter] public string? DisplayName { get; set; } + + /// + /// Gets the associated . + /// This property is uninitialized if the input does not have a parent . + /// + protected EditContext EditContext { get; set; } = default!; + + /// + /// Gets the for the bound value. + /// protected internal FieldIdentifier FieldIdentifier { get; set; } - protected TValue CurrentValue + /// + /// Gets or sets the current value of the input. + /// + protected TValue? CurrentValue { get => Value; set @@ -48,21 +78,24 @@ protected TValue CurrentValue } } - protected string CurrentValueAsString + /// + /// Gets or sets the current value of the input, represented as a string. + /// + protected string? CurrentValueAsString { get => FormatValueAsString(CurrentValue); set { - if (EditContext == null) - { - if (TryParseValueFromString(value, out var parsedValue, out var _)) - { - CurrentValue = parsedValue; - } + //if (EditContext == null) + //{ + // if (TryParseValueFromString(value, out var parsedValue, out var _)) + // { + // CurrentValue = parsedValue; + // } - // If we are not in the context of an edit form, don't do anything with the current value. - return; - } + // // If we are not in the context of an edit form, don't do anything with the current value. + // return; + //} _parsingValidationMessages?.Clear(); @@ -85,51 +118,63 @@ protected string CurrentValueAsString { parsingFailed = true; - if (_parsingValidationMessages == null) + // EditContext may be null if the input is not a child component of EditForm. + if (EditContext is not null) { - _parsingValidationMessages = new ValidationMessageStore(EditContext); - } - - _parsingValidationMessages.Add(FieldIdentifier, validationErrorMessage); + _parsingValidationMessages ??= new ValidationMessageStore(EditContext); + _parsingValidationMessages.Add(FieldIdentifier, validationErrorMessage); - // Since we're not writing to CurrentValue, we'll need to notify about modification from here - EditContext.NotifyFieldChanged(FieldIdentifier); + // Since we're not writing to CurrentValue, we'll need to notify about modification from here + EditContext.NotifyFieldChanged(FieldIdentifier); + } } // We can skip the validation notification if we were previously valid and still are if (parsingFailed || _previousParsingAttemptFailed) { - EditContext.NotifyValidationStateChanged(); + EditContext?.NotifyValidationStateChanged(); _previousParsingAttemptFailed = parsingFailed; } } } + /// + /// Constructs an instance of . + /// protected FluentInputBase() { _validationStateChangedHandler = OnValidateStateChanged; } - protected virtual string FormatValueAsString(TValue value) + /// + /// Formats the value as a string. Derived classes can override this to determine the formating used for . + /// + /// The value to format. + /// A string representation of the value. + protected virtual string? FormatValueAsString(TValue? value) => value?.ToString(); - protected abstract bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage); - - private string FieldClass - => EditContext?.FieldCssClass(FieldIdentifier); - + /// + /// Parses a string to create an instance of . Derived classes can override this to change how + /// interprets incoming values. + /// + /// The string value to be parsed. + /// An instance of . + /// If the value could not be parsed, provides a validation error message. + /// True if the value could be parsed; otherwise false. + protected abstract bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out TValue result, [NotNullWhen(false)] out string? validationErrorMessage); + + /// + /// Gets a CSS class string that combines the class attribute and and a string indicating + /// the status of the field being edited (a combination of "modified", "valid", and "invalid"). + /// Derived components should typically use this value for the primary HTML element's 'class' attribute. + /// protected string CssClass { get { - if (AdditionalAttributes != null && - AdditionalAttributes.TryGetValue("class", out var @class) && - !string.IsNullOrEmpty(Convert.ToString(@class, CultureInfo.InvariantCulture))) - { - return $"{@class} {FieldClass}"; - } - - return FieldClass; // Never null or empty + var fieldClass = EditContext?.FieldCssClass(FieldIdentifier) ?? string.Empty; + return CombineClassNames(AdditionalAttributes, fieldClass); } } @@ -139,16 +184,10 @@ public override Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); - if(EditContext != null || CascadedEditContext != null) + if (!_hasInitializedParameters) { // This is the first run // Could put this logic in OnInit, but its nice to avoid forcing people who override OnInit to call base.OnInit() - if (CascadedEditContext == null) - { - throw new InvalidOperationException($"{GetType()} requires a cascading parameter " + - $"of type {nameof(AspNetCore.Components.Forms.EditContext)}. For example, you can use {GetType().FullName} inside " + - $"an {nameof(EditForm)}."); - } if (ValueExpression == null) { @@ -156,30 +195,35 @@ public override Task SetParametersAsync(ParameterView parameters) $"parameter. Normally this is provided automatically when using 'bind-Value'."); } - EditContext = CascadedEditContext; FieldIdentifier = FieldIdentifier.Create(ValueExpression); - _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); - EditContext.OnValidationStateChanged += _validationStateChangedHandler; - if (CascadedEditContext != EditContext) + if (CascadedEditContext != null) { - // Not the first run - - // We don't support changing EditContext because it's messy to be clearing up state and event - // handlers for the previous one, and there's no strong use case. If a strong use case - // emerges, we can consider changing this. - throw new InvalidOperationException($"{GetType()} does not support changing the " + - $"{nameof(AspNetCore.Components.Forms.EditContext)} dynamically."); + EditContext = CascadedEditContext; + EditContext.OnValidationStateChanged += _validationStateChangedHandler; } - UpdateAdditionalValidationAttributes(); + _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); + _hasInitializedParameters = true; + } + else if (CascadedEditContext != EditContext) + { + // Not the first run + + // We don't support changing EditContext because it's messy to be clearing up state and event + // handlers for the previous one, and there's no strong use case. If a strong use case + // emerges, we can consider changing this. + throw new InvalidOperationException($"{GetType()} does not support changing the " + + $"{nameof(AspNetCore.Components.Forms.EditContext)} dynamically."); } + UpdateAdditionalValidationAttributes(); + // For derived components, retain the usual lifecycle with OnInit/OnParametersSet/etc. return base.SetParametersAsync(ParameterView.Empty); } - private void OnValidateStateChanged(object sender, ValidationStateChangedEventArgs eventArgs) + private void OnValidateStateChanged(object? sender, ValidationStateChangedEventArgs eventArgs) { UpdateAdditionalValidationAttributes(); @@ -188,7 +232,7 @@ private void OnValidateStateChanged(object sender, ValidationStateChangedEventAr private void UpdateAdditionalValidationAttributes() { - if (EditContext == null) + if (EditContext is null) { return; } @@ -232,7 +276,11 @@ private void UpdateAdditionalValidationAttributes() } } - private bool ConvertToDictionary(IReadOnlyDictionary source, out Dictionary result) + /// + /// Returns a dictionary with the same values as the specified . + /// + /// true, if a new dictrionary with copied values was created. false - otherwise. + private bool ConvertToDictionary(IReadOnlyDictionary? source, out Dictionary result) { var newDictionaryCreated = true; if (source == null) @@ -262,11 +310,34 @@ protected virtual void Dispose(bool disposing) void IDisposable.Dispose() { - if (EditContext != null) + // When initialization in the SetParametersAsync method fails, the EditContext property can remain equal to null + if (EditContext is not null) { EditContext.OnValidationStateChanged -= _validationStateChangedHandler; } Dispose(disposing: true); } + + public static string CombineClassNames(IReadOnlyDictionary? additionalAttributes, string classNames) + { + if (additionalAttributes is null || !additionalAttributes.TryGetValue("class", out var @class)) + { + return classNames; + } + + var classAttributeValue = Convert.ToString(@class, CultureInfo.InvariantCulture); + + if (string.IsNullOrEmpty(classAttributeValue)) + { + return classNames; + } + + if (string.IsNullOrEmpty(classNames)) + { + return classAttributeValue; + } + + return $"{classAttributeValue} {classNames}"; + } } } From da4949814b7c331c2e5b55a6f542564e1004f49b Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 10:58:11 +0200 Subject: [PATCH 05/28] Update component project to only optimie on Release build --- .../Microsoft.Fast.Components.FluentUI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 190309e1a0..80b894795e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -21,7 +21,7 @@ - true + False 4 true false From 0fe610b4d8ec9be3601c2589a2ce312b50ec6035 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 10:58:11 +0200 Subject: [PATCH 06/28] Update component project to only optimize on Release build --- .../Microsoft.Fast.Components.FluentUI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 190309e1a0..80b894795e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -21,7 +21,7 @@ - true + False 4 true false From 59b7768ba5741c8ae433fb31cb1965e3f65b84c9 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 11:17:21 +0200 Subject: [PATCH 07/28] Revert SetParametersAsync logic --- src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs index f3238482f7..7e26f756ad 100644 --- a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs +++ b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs @@ -12,7 +12,6 @@ namespace Microsoft.Fast.Components.FluentUI public abstract class FluentInputBase : ComponentBase, IDisposable { private readonly EventHandler _validationStateChangedHandler; - private bool _hasInitializedParameters; private bool _previousParsingAttemptFailed; private ValidationMessageStore? _parsingValidationMessages; private Type? _nullableUnderlyingType; @@ -184,7 +183,7 @@ public override Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); - if (!_hasInitializedParameters) + if (EditContext != null || CascadedEditContext != null) { // This is the first run // Could put this logic in OnInit, but its nice to avoid forcing people who override OnInit to call base.OnInit() @@ -204,7 +203,6 @@ public override Task SetParametersAsync(ParameterView parameters) } _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); - _hasInitializedParameters = true; } else if (CascadedEditContext != EditContext) { From 7032a8db56d733bc54caf92600798ee0e557e0c8 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 12:55:43 +0200 Subject: [PATCH 08/28] Move RTL/Theme switches to webcomponents page --- .../Components/FluentSwitchTest.razor | 22 ------------------- .../Pages/Webcomponents.razor | 16 ++++++++++++++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/examples/FluentUIServerSample/Components/FluentSwitchTest.razor b/examples/FluentUIServerSample/Components/FluentSwitchTest.razor index 402fbf13e8..7d320a1b9d 100644 --- a/examples/FluentUIServerSample/Components/FluentSwitchTest.razor +++ b/examples/FluentUIServerSample/Components/FluentSwitchTest.razor @@ -1,25 +1,3 @@ -
- - - Direction - ltr - rtl - - - - Theme - Dark - Light - -

Switch

Default

diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 3d5b36904d..17c52e2837 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -103,6 +103,22 @@
+
+ + + Direction + ltr + rtl + + + + Theme + Dark + Light + +
@switch (Target) { case "Accordion": From 2f50d53435261d0ec5dd3904a7b9d7f11ef82324 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 13:52:58 +0200 Subject: [PATCH 09/28] Enable Hot Reload Make Theme switch work --- .../Pages/Webcomponents.razor | 98 ++++++++++--------- .../Properties/launchSettings.json | 4 +- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 17c52e2837..f1057e91a7 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -1,7 +1,57 @@ @page "/webcomponents/{Target?}" + + + @using FluentUIServerSample.Components + +
- +

Fluent components test page

  • @@ -113,7 +163,7 @@ rtl - + Theme Dark Light @@ -223,50 +273,8 @@ }
+ - @code{ [Parameter] public string? Target { get; set; } = null; diff --git a/examples/FluentUIServerSample/Properties/launchSettings.json b/examples/FluentUIServerSample/Properties/launchSettings.json index 572143dbe9..632be8cfb7 100644 --- a/examples/FluentUIServerSample/Properties/launchSettings.json +++ b/examples/FluentUIServerSample/Properties/launchSettings.json @@ -13,12 +13,14 @@ "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "hotReloadProfile": "aspnetcore" }, "FluentUIServerSample": { "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": true, + "hotReloadProfile": "aspnetcore", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" From 8bd654a1de24fb92196198b93706ecab96178aac Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 15:41:09 +0200 Subject: [PATCH 10/28] Upgrade projects to .NET 6 --- examples/FluentUIServerSample/FluentUIServerSample.csproj | 3 +-- .../Microsoft.Fast.Components.FluentUI.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/FluentUIServerSample/FluentUIServerSample.csproj b/examples/FluentUIServerSample/FluentUIServerSample.csproj index 014d3f0b8a..1edfae927f 100644 --- a/examples/FluentUIServerSample/FluentUIServerSample.csproj +++ b/examples/FluentUIServerSample/FluentUIServerSample.csproj @@ -5,8 +5,7 @@ - net5.0 - 5.0.10 + net6.0 diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 4e22af1c7c..28a31c9a1d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 Microsoft.Fast.Components.FluentUI Microsoft © Microsoft Corporation. All rights reserved. @@ -10,7 +10,7 @@ https://github.com/microsoft/fast-blazor MIT Fluent UI Web Components library for Blazor on .NET - Web Components, .NET, FluentUI, FAST, Blazor, .NET 5.0 + Web Components, .NET, FluentUI, FAST, Blazor, .NET 6.0 Microsoft Fluent UI Components Library for Blazor on FAST Authored by the Microsoft FAST team. true @@ -24,7 +24,7 @@ 4 true false - bin\Debug\net5.0\Microsoft.Fast.Components.FluentUI.xml + bin\Debug\net6.0\Microsoft.Fast.Components.FluentUI.xml 1701;1702,8669,1591 @@ -36,7 +36,7 @@ - + From b29ab95eb54c6b1618c1293322c9f7d781c20ae1 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 15:50:23 +0200 Subject: [PATCH 11/28] Enable nullable for sample project --- .../Components/FluentDialogTest.razor | 6 +++--- .../FluentUIServerSample.csproj | 3 ++- .../Pages/ComponentBindings.razor | 10 ++++----- .../Pages/Error.cshtml.cs | 10 +++------ .../Pages/RawBindings.razor | 21 +++++++++---------- .../Pages/Webcomponents.razor | 4 ++-- 6 files changed, 25 insertions(+), 29 deletions(-) diff --git a/examples/FluentUIServerSample/Components/FluentDialogTest.razor b/examples/FluentUIServerSample/Components/FluentDialogTest.razor index 4188a7237b..299b17fed6 100644 --- a/examples/FluentUIServerSample/Components/FluentDialogTest.razor +++ b/examples/FluentUIServerSample/Components/FluentDialogTest.razor @@ -15,12 +15,12 @@ @code{ - private FluentDialog MyFluentDialog; + private FluentDialog? MyFluentDialog; public bool ModalHidden { get; set; } = true; - private void OnOpenModalRefButtonClick() => MyFluentDialog.Show(); - private void OnCloseModalRefButtonClick() => MyFluentDialog.Hide(); + private void OnOpenModalRefButtonClick() => MyFluentDialog!.Show(); + private void OnCloseModalRefButtonClick() => MyFluentDialog!.Hide(); private void OnOpenModalParameterButtonClick() => ModalHidden = false; private void OnCloseModalParameterButtonClick() => ModalHidden = true; diff --git a/examples/FluentUIServerSample/FluentUIServerSample.csproj b/examples/FluentUIServerSample/FluentUIServerSample.csproj index 1edfae927f..f03c13a521 100644 --- a/examples/FluentUIServerSample/FluentUIServerSample.csproj +++ b/examples/FluentUIServerSample/FluentUIServerSample.csproj @@ -1,4 +1,4 @@ - + @@ -6,6 +6,7 @@ net6.0 + enable diff --git a/examples/FluentUIServerSample/Pages/ComponentBindings.razor b/examples/FluentUIServerSample/Pages/ComponentBindings.razor index 9b5259088e..88b4d3c102 100644 --- a/examples/FluentUIServerSample/Pages/ComponentBindings.razor +++ b/examples/FluentUIServerSample/Pages/ComponentBindings.razor @@ -158,22 +158,22 @@ private class FormModel { [Required] - public string SelectValue { get; set; } + public string? SelectValue { get; set; } [Required] - public string TextFieldValue { get; set; } + public string? TextFieldValue { get; set; } [Required] public int? NumberFieldValue { get; set; } [Required] - public string TextAreaValue { get; set; } + public string? TextAreaValue { get; set; } [Required] - public string ComboboxValue { get; set; } + public string? ComboboxValue { get; set; } [Required] - public string RadioGroupValue { get; set; } + public string? RadioGroupValue { get; set; } [Required] public bool CheckboxValue { get; set; } diff --git a/examples/FluentUIServerSample/Pages/Error.cshtml.cs b/examples/FluentUIServerSample/Pages/Error.cshtml.cs index cd304bb09e..f13f59953b 100644 --- a/examples/FluentUIServerSample/Pages/Error.cshtml.cs +++ b/examples/FluentUIServerSample/Pages/Error.cshtml.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; +using System.Diagnostics; namespace FluentUIServerSample.Pages { @@ -13,7 +9,7 @@ namespace FluentUIServerSample.Pages [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - public string RequestId { get; set; } + public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); diff --git a/examples/FluentUIServerSample/Pages/RawBindings.razor b/examples/FluentUIServerSample/Pages/RawBindings.razor index f631fbeb95..468002831e 100644 --- a/examples/FluentUIServerSample/Pages/RawBindings.razor +++ b/examples/FluentUIServerSample/Pages/RawBindings.razor @@ -121,12 +121,12 @@
@code { - string TextFieldValueImplicit; - string TextFieldValueExplicit; + string? TextFieldValueImplicit; + string? TextFieldValueExplicit; int NumberFieldValueImplicit; int NumberFieldValueExplicit; - string TextAreaValueImplicit; - string TextAreaValueExplicit; + string? TextAreaValueImplicit; + string? TextAreaValueExplicit; bool CheckboxValueImplicit; bool CheckboxValueExplicit; bool SwitchValueImplicit; @@ -135,13 +135,12 @@ bool FluentMenuItemValueExplicit; int SliderValueImplicit; int SliderValueExplicit; - string SelectValueImplicit; - string SelectValueExplicit; - string RadioGroupValueImplicit; - string RadioGroupValueExplicit; + string? SelectValueImplicit; + string? SelectValueExplicit; + string? RadioGroupValueImplicit; + string? RadioGroupValueExplicit; int ListboxIndexValueImplicit; int ListboxIndexValueExplicit; - string ComboboxValueImplicit; - string ComboboxValueExplicit; - + string? ComboboxValueImplicit; + string? ComboboxValueExplicit; } diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 7488a82c32..67ec307e07 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -283,6 +283,6 @@ } -@code { - [Parameter] public string Target { get; set; } = null; +@code{ + [Parameter] public string? Target { get; set; } = null; } \ No newline at end of file From 9be1dc4ca97ef7851a0e5d70a0e149f73753cfa9 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 28 Sep 2021 16:06:23 +0200 Subject: [PATCH 12/28] Enable Nullable for component project (excluded that changes related to change inheritance to InputBase) --- src/Microsoft.Fast.Components.FluentUI/Appearance.cs | 6 ++---- src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs | 8 ++++---- src/Microsoft.Fast.Components.FluentUI/Color.cs | 8 ++++---- .../Components/FluentAccordion.razor | 4 ++-- .../Components/FluentAccordionItem.razor | 4 ++-- .../Components/FluentAnchor.razor | 6 +++--- .../Components/FluentBadge.razor | 4 ++-- .../Components/FluentBreadcrumb.razor | 4 ++-- .../Components/FluentBreadcrumbItem.razor | 6 +++--- .../Components/FluentButton.razor | 4 ++-- .../Components/FluentCard.razor | 4 ++-- .../Components/FluentCheckbox.razor | 4 ++-- .../Components/FluentCombobox.razor | 2 +- .../Components/FluentDialog.razor | 4 ++-- .../Components/FluentDivider.razor | 4 ++-- .../Components/FluentFlipper.razor | 4 ++-- .../Components/FluentListbox.razor | 4 ++-- .../Components/FluentMenu.razor | 4 ++-- .../Components/FluentMenuItem.razor | 4 ++-- .../Components/FluentNumberField.razor | 10 +++++----- .../Components/FluentOption.razor | 6 +++--- .../Components/FluentProgress.razor | 4 ++-- .../Components/FluentProgressRing.razor | 4 ++-- .../Components/FluentRadio.razor | 6 +++--- .../Components/FluentRadioGroup.razor | 4 ++-- .../Components/FluentSelect.razor | 4 ++-- .../Components/FluentSkeleton.razor | 6 +++--- .../Components/FluentSlider.razor | 4 ++-- .../Components/FluentSliderLabel.razor | 4 ++-- .../Components/FluentSwitch.razor | 4 ++-- .../Components/FluentTab.razor | 4 ++-- .../Components/FluentTabPanel.razor | 4 ++-- .../Components/FluentTabs.razor | 4 ++-- .../Components/FluentTextArea.razor | 4 ++-- .../Components/FluentTextField.razor | 4 ++-- .../Components/FluentTreeItem.razor | 4 ++-- .../Components/FluentTreeView.razor | 4 ++-- .../Components/NavLinkFluentAnchor.cs | 8 ++------ src/Microsoft.Fast.Components.FluentUI/Direction.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs | 4 ++-- .../Microsoft.Fast.Components.FluentUI.csproj | 1 + src/Microsoft.Fast.Components.FluentUI/Orientation.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/Resize.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/Shape.cs | 4 ++-- .../TextFieldType.cs | 6 ++---- 45 files changed, 100 insertions(+), 107 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs index c62398311f..1b3ffe1f0c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Fast.Components.FluentUI { @@ -20,8 +18,8 @@ public enum Appearance internal static class AppearanceExtensions { private static Dictionary _appearanceValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Appearance? value) => value == null ? null : _appearanceValues[value.Value]; + public static string? ToAttributeValue(this Appearance? value) => value == null ? null : _appearanceValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs index 42cf879418..60ba4e83b5 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs @@ -14,9 +14,9 @@ public enum Autocomplete internal static class AutocompleteExtensions { private static Dictionary _autocompleteValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Autocomplete? value) => value == null ? null : _autocompleteValues[value.Value]; + public static string? ToAttributeValue(this Autocomplete? value) => value == null ? null : _autocompleteValues[value.Value]; } public enum Position @@ -28,8 +28,8 @@ public enum Position internal static class PositionExtensions { private static Dictionary _positionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Position? value) => value == null ? null : _positionValues[value.Value]; + public static string? ToAttributeValue(this Position? value) => value == null ? null : _positionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Color.cs b/src/Microsoft.Fast.Components.FluentUI/Color.cs index 243da3600e..4ea51e596f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Color.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Color.cs @@ -13,9 +13,9 @@ public enum Color internal static class ColorExtensions { private static Dictionary _colorValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Color? value) => value == null ? null : _colorValues[value.Value]; + public static string? ToAttributeValue(this Color? value) => value == null ? null : _colorValues[value.Value]; } public enum Fill @@ -27,8 +27,8 @@ public enum Fill internal static class FillExtensions { private static Dictionary _fillValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Fill? value) => value == null ? null : _fillValues[value.Value]; + public static string? ToAttributeValue(this Fill? value) => value == null ? null : _fillValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor index ab2eaab376..6eb43f03e9 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordion.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public ExpandMode? ExpandMode { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor index c08d3efd8d..68bb0eab33 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAccordionItem.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? Expanded { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor index 4966e472df..45817f2c60 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchor.razor @@ -1,11 +1,11 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor index c9abdcd575..c26f7515d4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBadge.razor @@ -7,7 +7,7 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor index 63272960f1..47a66f6997 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumb.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor index c4fee0db5d..4af1f80142 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentBreadcrumbItem.razor @@ -1,9 +1,9 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor index e4e2457939..1ea1583b75 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentButton.razor @@ -7,7 +7,7 @@ [Parameter] public bool? Autofocus { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor index bddcba0796..0ba27dc22d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCard.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor index 74f0ad4b2b..4f96369362 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor @@ -3,13 +3,13 @@ @ChildContent @code { - [Parameter] public string Href { get; set; } + [Parameter] public string? Href { get; set; } [Parameter] public bool? Disabled { get; set; } [Parameter] public bool? Required { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out bool result, out string validationErrorMessage) => throw new NotSupportedException($"This component does not parse string inputs. Bind to the '{nameof(CurrentValue)}' property, not '{nameof(CurrentValueAsString)}'."); diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor index b33aac87fd..51083aa8c3 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor @@ -10,7 +10,7 @@ [Parameter] public Position? Position { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor index e60a603e67..727156733e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDialog.razor @@ -3,9 +3,9 @@ { [Parameter] public bool? Modal { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } [Parameter] public bool Hidden { get; set; } = false; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor index 81210f4162..f318d3fb26 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDivider.razor @@ -1,7 +1,7 @@ @ChildContent @code { - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor index bdeee2cb2f..8caa7667a2 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentFlipper.razor @@ -5,7 +5,7 @@ [Parameter] public Direction? Direction { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor index 4d0e448577..ac1e9415f6 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentListbox.razor @@ -1,7 +1,7 @@ @ChildContent @code { - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor index 4cf878fa1c..1f873a9c29 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenu.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor index b4d8df9c38..06b223eb69 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentMenuItem.razor @@ -4,7 +4,7 @@ [Parameter] public bool? Checked { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor index d6154c6e84..b0573c3af3 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor @@ -34,14 +34,14 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } [Parameter] public string ParsingErrorMessage { get; set; } = "The {0} field must be a number."; - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter] public string Min { get; set; } = GetMinOrMaxValue("MinValue"); - [Parameter] public string Max { get; set; } = GetMinOrMaxValue("MaxValue"); + [Parameter] public string? Min { get; set; } = GetMinOrMaxValue("MinValue"); + [Parameter] public string? Max { get; set; } = GetMinOrMaxValue("MaxValue"); [Parameter] public int MinLength { get; set; } = 1; [Parameter] public int MaxLength { get; set; } = 14; [Parameter] public int Step { get; set; } = _stepAttributeValue; @@ -119,7 +119,7 @@ } } - private static string GetMinOrMaxValue(string name) + private static string? GetMinOrMaxValue(string name) { var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor index 39ea192485..11c932ca48 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentOption.razor @@ -3,11 +3,11 @@ { [Parameter] public bool? Disabled { get; set; } - [Parameter] public string Value { get; set; } + [Parameter] public string? Value { get; set; } [Parameter] public bool? Selected { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor index 5ccc6a2484..24e37836be 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgress.razor @@ -8,7 +8,7 @@ [Parameter] public bool? Paused { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor index 078c912652..1a5fbc18c2 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentProgressRing.razor @@ -8,7 +8,7 @@ [Parameter] public bool? Paused { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor index 5f8af2db2a..3ba1221e7e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadio.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public string Value { get; set; } + [Parameter] public string? Value { get; set; } [Parameter] public bool? Required { get; set; } @@ -8,7 +8,7 @@ [Parameter] public bool? Checked { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor index acf51456f6..619cd43620 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor @@ -2,13 +2,13 @@ @ChildContent @code{ - [Parameter] public string Name { get; set; } + [Parameter] public string? Name { get; set; } [Parameter] public bool? Required { get; set; } [Parameter] public Orientation? Orientation { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor index 1f373fbb54..048b390760 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor @@ -5,11 +5,11 @@ [Parameter] public bool? Filled { get; set; } - [Parameter] public string Name { get; set; } + [Parameter] public string? Name { get; set; } [Parameter] public Position? Position { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor index 21ed0d8dc3..2413e91694 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSkeleton.razor @@ -5,9 +5,9 @@ [Parameter] public bool? Shimmer { get; set; } - [Parameter] public string Pattern { get; set; } + [Parameter] public string? Pattern { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor index 0a6e582f25..7c14bf9952 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor @@ -15,7 +15,7 @@ [Parameter] public bool? Readonly { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out int result, out string validationErrorMessage) { @@ -31,7 +31,7 @@ } } - protected override string FormatValueAsString(int value) + protected override string? FormatValueAsString(int value) { return BindConverter.FormatValue(value, CultureInfo.InvariantCulture); } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor index 580e3f5d55..8f7e936db8 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSliderLabel.razor @@ -1,10 +1,10 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public int? Position { get; set; } [Parameter] public bool? HideMark { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor index 01f031bf62..1a0d7b0630 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSwitch.razor @@ -6,7 +6,7 @@ [Parameter] public bool? Required { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor index ef61a728d9..1aae0b3c94 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTab.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor index a8d86b84dc..a3460fec27 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabPanel.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor index 4aee601b48..0bb3be1a83 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTabs.razor @@ -4,7 +4,7 @@ [Parameter] public Orientation? Orientation { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor index fc41500cb5..e06e6649e4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor @@ -13,9 +13,9 @@ [Parameter] public Appearance? Appearance { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor index 395d730566..a2178c112e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor @@ -30,7 +30,7 @@ [Parameter] public TextFieldType? TextFieldType { get; set; } - [Parameter] public string Placeholder { get; set; } + [Parameter] public string? Placeholder { get; set; } [Parameter] public int? MinLength { get; set; } @@ -41,7 +41,7 @@ //Pattern //List - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor index d350b6a8b5..1ebecfce9e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeItem.razor @@ -1,6 +1,6 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? Disabled { get; set; } @@ -8,5 +8,5 @@ [Parameter] public bool? Expanded { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor index 14df3beb27..8c6f9dcc8f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTreeView.razor @@ -1,8 +1,8 @@ @ChildContent @code{ - [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public bool? RenderCollapsedNodes { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs b/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs index 79aa84b63a..ae301e066d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Components/NavLinkFluentAnchor.cs @@ -1,16 +1,12 @@ - using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Rendering; using Microsoft.AspNetCore.Components.Routing; -using System; -using System.Collections.Generic; -using System.Linq; namespace Microsoft.Fast.Components.FluentUI { public class NavLinkFluentAnchor : NavLink - { - [Parameter] public string Href { get; set; } + { + [Parameter] public string? Href { get; set; } [Parameter] public Appearance? Appearance { get; set; } diff --git a/src/Microsoft.Fast.Components.FluentUI/Direction.cs b/src/Microsoft.Fast.Components.FluentUI/Direction.cs index 1a9e66c5f2..76cded635a 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Direction.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Direction.cs @@ -13,8 +13,8 @@ public enum Direction internal static class DirectionExtensions { private static Dictionary _directionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Direction? value) => value == null ? null : _directionValues[value.Value]; + public static string? ToAttributeValue(this Direction? value) => value == null ? null : _directionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs index fdef294b20..f339d2f8bd 100644 --- a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs +++ b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs @@ -12,8 +12,8 @@ public enum ExpandMode internal static class ExpandModeExtensions { private static Dictionary _expandModeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this ExpandMode? value) => value == null ? null : _expandModeValues[value.Value]; + public static string? ToAttributeValue(this ExpandMode? value) => value == null ? null : _expandModeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 28a31c9a1d..041605afe2 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -17,6 +17,7 @@ 0.3.0 0.3.0 false + enable
diff --git a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs index f47ec1d6bf..22b9bea07c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs @@ -13,8 +13,8 @@ public enum Orientation internal static class OrientationExtensions { private static Dictionary _orientationValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Orientation? value) => value == null ? null : _orientationValues[value.Value]; + public static string? ToAttributeValue(this Orientation? value) => value == null ? null : _orientationValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Resize.cs b/src/Microsoft.Fast.Components.FluentUI/Resize.cs index 56746bcdbf..1bb969303c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Resize.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Resize.cs @@ -14,8 +14,8 @@ public enum Resize internal static class ResizeExtensions { private static Dictionary _resizeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Resize? value) => value == null ? null : _resizeValues[value.Value]; + public static string? ToAttributeValue(this Resize? value) => value == null ? null : _resizeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Shape.cs b/src/Microsoft.Fast.Components.FluentUI/Shape.cs index 4d8917dfb3..be8e188807 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Shape.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Shape.cs @@ -13,8 +13,8 @@ public enum Shape internal static class ShapeExtensions { private static Dictionary _orientationValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Shape? value) => value == null ? null : _orientationValues[value.Value]; + public static string? ToAttributeValue(this Shape? value) => value == null ? null : _orientationValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs index dc73e34593..bf97038620 100644 --- a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs +++ b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Fast.Components.FluentUI { @@ -18,8 +16,8 @@ public enum TextFieldType internal static class TextFieldTypeExtensions { private static Dictionary _textFieldTypeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this TextFieldType? value) => value == null ? null : _textFieldTypeValues[value.Value]; + public static string? ToAttributeValue(this TextFieldType? value) => value == null ? null : _textFieldTypeValues[value.Value]; } } From ed029ba10fb422079a6f380d8d6a2eee38cbcc33 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 10:47:45 +0200 Subject: [PATCH 13/28] Enable Nullable for FluentInputBase derivates --- .../Components/FluentCheckbox.razor | 10 +- .../Components/FluentCombobox.razor | 13 +- .../Components/FluentNumberField.razor | 53 ++--- .../Components/FluentRadioGroup.razor | 4 +- .../Components/FluentSelect.razor | 16 +- .../Components/FluentSlider.razor | 14 +- .../Components/FluentTextArea.razor | 17 +- .../Components/FluentTextField.razor | 6 +- .../Components/_Imports.razor | 1 + .../FluentInputBase.cs | 213 ++++++++++++------ 10 files changed, 231 insertions(+), 116 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor index 4f96369362..fd4b530553 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCheckbox.razor @@ -1,6 +1,12 @@ @inherits FluentInputBase @using System.Globalization -@ChildContent + + @ChildContent + @code { [Parameter] public string? Href { get; set; } @@ -11,6 +17,6 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out bool result, out string validationErrorMessage) => + protected override bool TryParseValueFromString(string? value, out bool result, [NotNullWhen(false)] out string? validationErrorMessage) => throw new NotSupportedException($"This component does not parse string inputs. Bind to the '{nameof(CurrentValue)}' property, not '{nameof(CurrentValueAsString)}'."); } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor index 51083aa8c3..b1d92d37b4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentCombobox.razor @@ -1,5 +1,12 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code { [Parameter] public bool? Filled { get; set; } @@ -12,7 +19,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor index b0573c3af3..ac766884ee 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor @@ -1,4 +1,4 @@ -@inherits FluentInputBase +@inherits FluentInputBase @typeparam TValue @using System.Globalization; @using System.Reflection; @@ -12,7 +12,7 @@ maxlength="@MaxLength" minlength="@MinLength" size="@Size" - change="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" + change="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" readonly="@Readonly" disabled="@Disabled" required="@Required" @@ -69,7 +69,7 @@ } } - protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out TValue? result, [NotNullWhen(false)] out string? validationErrorMessage) { if (BindConverter.TryConvertTo(value, CultureInfo.InvariantCulture, out result)) { @@ -123,7 +123,7 @@ { var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); - FieldInfo field = targetType.GetField(name, BindingFlags.Public | BindingFlags.Static); + FieldInfo? field = targetType.GetField(name, BindingFlags.Public | BindingFlags.Static); if (field == null) { throw new InvalidOperationException("Invalid type argument for FluentNumberField: " + typeof(TValue).Name); @@ -131,30 +131,31 @@ var value = field.GetValue(null); - - if (targetType == typeof(int) || targetType == typeof(short)) - { - return value.ToString(); - } - - if (targetType == typeof(long)) - { - //Precision in underlying Fast script is limited to 12 digits - return name == "MinValue" ? "-999999999999" : "999999999999"; - } - if (targetType == typeof(float)) + if (value is not null) { - return ((float)value).ToString(CultureInfo.InvariantCulture); + if (targetType == typeof(int) || targetType == typeof(short)) + { + return value.ToString(); + } + + if (targetType == typeof(long)) + { + //Precision in underlying Fast script is limited to 12 digits + return name == "MinValue" ? "-999999999999" : "999999999999"; + } + if (targetType == typeof(float)) + { + return ((float)value).ToString(CultureInfo.InvariantCulture); + } + if (targetType == typeof(double)) + { + return ((double)value).ToString(CultureInfo.InvariantCulture); + } + if (targetType == typeof(decimal)) + { + return ((decimal)value).ToString("G12", CultureInfo.InvariantCulture); + } } - if (targetType == typeof(double)) - { - return ((double)value).ToString(CultureInfo.InvariantCulture); - } - if (targetType == typeof(decimal)) - { - return ((decimal)value).ToString("G12", CultureInfo.InvariantCulture); - } - // This should never occur return "0"; } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor index 619cd43620..96514adc58 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentRadioGroup.razor @@ -1,4 +1,4 @@ -@inherits FluentInputBase +@inherits FluentInputBase @ChildContent @code{ @@ -10,7 +10,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor index 048b390760..e6fd03059f 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSelect.razor @@ -1,17 +1,25 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code{ [Parameter] public bool? Disabled { get; set; } [Parameter] public bool? Filled { get; set; } [Parameter] public string? Name { get; set; } - + [Parameter] public Position? Position { get; set; } [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor index 7c14bf9952..839d9d1304 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentSlider.razor @@ -1,6 +1,16 @@ @inherits FluentInputBase @using System.Globalization -@ChildContent + + @ChildContent + @code{ [Parameter] public Orientation? Orientation { get; set; } @@ -17,7 +27,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out int result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out int result, [NotNullWhen(false)] out string? validationErrorMessage) { if (BindConverter.TryConvertTo(value, CultureInfo.InvariantCulture, out result)) { diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor index e06e6649e4..6bd611374c 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextArea.razor @@ -1,5 +1,16 @@ -@inherits FluentInputBase -@ChildContent +@inherits FluentInputBase + + @ChildContent + @code{ [Parameter] public bool? Disabled { get; set; } @@ -17,7 +28,7 @@ [Parameter] public RenderFragment? ChildContent { get; set; } - protected override bool TryParseValueFromString(string value, out string result, out string validationErrorMessage) + protected override bool TryParseValueFromString(string? value, out string? result, [NotNullWhen(false)] out string? validationErrorMessage) { result = value; validationErrorMessage = null; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor index a2178c112e..b58a2e9dac 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTextField.razor @@ -1,8 +1,8 @@ -@inherits FluentInputBase +@inherits FluentInputBase : ComponentBase, IDisposable { private readonly EventHandler _validationStateChangedHandler; + private bool _hasInitializedParameters; private bool _previousParsingAttemptFailed; - private ValidationMessageStore _parsingValidationMessages; - private Type _nullableUnderlyingType; - - [CascadingParameter] EditContext CascadedEditContext { get; set; } - - [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary AdditionalAttributes { get; set; } - + private ValidationMessageStore? _parsingValidationMessages; + private Type? _nullableUnderlyingType; + + [CascadingParameter] private EditContext? CascadedEditContext { get; set; } + + /// + /// Gets or sets a collection of additional attributes that will be applied to the created element. + /// + [Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary? AdditionalAttributes { get; set; } + + /// + /// Gets or sets the value of the input. This should be used with two-way binding. + /// + /// + /// @bind-Value="model.PropertyName" + /// [Parameter] - public TValue Value { get; set; } + public TValue? Value { get; set; } + /// + /// Gets or sets a callback that updates the bound value. + /// [Parameter] public EventCallback ValueChanged { get; set; } - [Parameter] public Expression> ValueExpression { get; set; } - - [Parameter] public string DisplayName { get; set; } - - protected EditContext EditContext { get; set; } - + /// + /// Gets or sets an expression that identifies the bound value. + /// + [Parameter] public Expression>? ValueExpression { get; set; } + + /// + /// Gets or sets the display name for this field. + /// This value is used when generating error messages when the input value fails to parse correctly. + /// + [Parameter] public string? DisplayName { get; set; } + + /// + /// Gets the associated . + /// This property is uninitialized if the input does not have a parent . + /// + protected EditContext EditContext { get; set; } = default!; + + /// + /// Gets the for the bound value. + /// protected internal FieldIdentifier FieldIdentifier { get; set; } - protected TValue CurrentValue + /// + /// Gets or sets the current value of the input. + /// + protected TValue? CurrentValue { get => Value; set @@ -48,21 +78,24 @@ protected TValue CurrentValue } } - protected string CurrentValueAsString + /// + /// Gets or sets the current value of the input, represented as a string. + /// + protected string? CurrentValueAsString { get => FormatValueAsString(CurrentValue); set { - if (EditContext == null) - { - if (TryParseValueFromString(value, out var parsedValue, out var _)) - { - CurrentValue = parsedValue; - } + //if (EditContext == null) + //{ + // if (TryParseValueFromString(value, out var parsedValue, out var _)) + // { + // CurrentValue = parsedValue; + // } - // If we are not in the context of an edit form, don't do anything with the current value. - return; - } + // // If we are not in the context of an edit form, don't do anything with the current value. + // return; + //} _parsingValidationMessages?.Clear(); @@ -85,51 +118,63 @@ protected string CurrentValueAsString { parsingFailed = true; - if (_parsingValidationMessages == null) + // EditContext may be null if the input is not a child component of EditForm. + if (EditContext is not null) { - _parsingValidationMessages = new ValidationMessageStore(EditContext); - } - - _parsingValidationMessages.Add(FieldIdentifier, validationErrorMessage); + _parsingValidationMessages ??= new ValidationMessageStore(EditContext); + _parsingValidationMessages.Add(FieldIdentifier, validationErrorMessage); - // Since we're not writing to CurrentValue, we'll need to notify about modification from here - EditContext.NotifyFieldChanged(FieldIdentifier); + // Since we're not writing to CurrentValue, we'll need to notify about modification from here + EditContext.NotifyFieldChanged(FieldIdentifier); + } } // We can skip the validation notification if we were previously valid and still are if (parsingFailed || _previousParsingAttemptFailed) { - EditContext.NotifyValidationStateChanged(); + EditContext?.NotifyValidationStateChanged(); _previousParsingAttemptFailed = parsingFailed; } } } + /// + /// Constructs an instance of . + /// protected FluentInputBase() { _validationStateChangedHandler = OnValidateStateChanged; } - protected virtual string FormatValueAsString(TValue value) + /// + /// Formats the value as a string. Derived classes can override this to determine the formating used for . + /// + /// The value to format. + /// A string representation of the value. + protected virtual string? FormatValueAsString(TValue? value) => value?.ToString(); - protected abstract bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage); - - private string FieldClass - => EditContext?.FieldCssClass(FieldIdentifier); - + /// + /// Parses a string to create an instance of . Derived classes can override this to change how + /// interprets incoming values. + /// + /// The string value to be parsed. + /// An instance of . + /// If the value could not be parsed, provides a validation error message. + /// True if the value could be parsed; otherwise false. + protected abstract bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out TValue result, [NotNullWhen(false)] out string? validationErrorMessage); + + /// + /// Gets a CSS class string that combines the class attribute and and a string indicating + /// the status of the field being edited (a combination of "modified", "valid", and "invalid"). + /// Derived components should typically use this value for the primary HTML element's 'class' attribute. + /// protected string CssClass { get { - if (AdditionalAttributes != null && - AdditionalAttributes.TryGetValue("class", out var @class) && - !string.IsNullOrEmpty(Convert.ToString(@class, CultureInfo.InvariantCulture))) - { - return $"{@class} {FieldClass}"; - } - - return FieldClass; // Never null or empty + var fieldClass = EditContext?.FieldCssClass(FieldIdentifier) ?? string.Empty; + return CombineClassNames(AdditionalAttributes, fieldClass); } } @@ -139,16 +184,10 @@ public override Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); - if(EditContext != null || CascadedEditContext != null) + if (!_hasInitializedParameters) { // This is the first run // Could put this logic in OnInit, but its nice to avoid forcing people who override OnInit to call base.OnInit() - if (CascadedEditContext == null) - { - throw new InvalidOperationException($"{GetType()} requires a cascading parameter " + - $"of type {nameof(AspNetCore.Components.Forms.EditContext)}. For example, you can use {GetType().FullName} inside " + - $"an {nameof(EditForm)}."); - } if (ValueExpression == null) { @@ -156,30 +195,35 @@ public override Task SetParametersAsync(ParameterView parameters) $"parameter. Normally this is provided automatically when using 'bind-Value'."); } - EditContext = CascadedEditContext; FieldIdentifier = FieldIdentifier.Create(ValueExpression); - _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); - EditContext.OnValidationStateChanged += _validationStateChangedHandler; - if (CascadedEditContext != EditContext) + if (CascadedEditContext != null) { - // Not the first run - - // We don't support changing EditContext because it's messy to be clearing up state and event - // handlers for the previous one, and there's no strong use case. If a strong use case - // emerges, we can consider changing this. - throw new InvalidOperationException($"{GetType()} does not support changing the " + - $"{nameof(AspNetCore.Components.Forms.EditContext)} dynamically."); + EditContext = CascadedEditContext; + EditContext.OnValidationStateChanged += _validationStateChangedHandler; } - UpdateAdditionalValidationAttributes(); + _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); + _hasInitializedParameters = true; + } + else if (CascadedEditContext != EditContext) + { + // Not the first run + + // We don't support changing EditContext because it's messy to be clearing up state and event + // handlers for the previous one, and there's no strong use case. If a strong use case + // emerges, we can consider changing this. + throw new InvalidOperationException($"{GetType()} does not support changing the " + + $"{nameof(AspNetCore.Components.Forms.EditContext)} dynamically."); } + UpdateAdditionalValidationAttributes(); + // For derived components, retain the usual lifecycle with OnInit/OnParametersSet/etc. return base.SetParametersAsync(ParameterView.Empty); } - private void OnValidateStateChanged(object sender, ValidationStateChangedEventArgs eventArgs) + private void OnValidateStateChanged(object? sender, ValidationStateChangedEventArgs eventArgs) { UpdateAdditionalValidationAttributes(); @@ -188,7 +232,7 @@ private void OnValidateStateChanged(object sender, ValidationStateChangedEventAr private void UpdateAdditionalValidationAttributes() { - if (EditContext == null) + if (EditContext is null) { return; } @@ -232,7 +276,11 @@ private void UpdateAdditionalValidationAttributes() } } - private bool ConvertToDictionary(IReadOnlyDictionary source, out Dictionary result) + /// + /// Returns a dictionary with the same values as the specified . + /// + /// true, if a new dictrionary with copied values was created. false - otherwise. + private bool ConvertToDictionary(IReadOnlyDictionary? source, out Dictionary result) { var newDictionaryCreated = true; if (source == null) @@ -262,11 +310,34 @@ protected virtual void Dispose(bool disposing) void IDisposable.Dispose() { - if (EditContext != null) + // When initialization in the SetParametersAsync method fails, the EditContext property can remain equal to null + if (EditContext is not null) { EditContext.OnValidationStateChanged -= _validationStateChangedHandler; } Dispose(disposing: true); } + + public static string CombineClassNames(IReadOnlyDictionary? additionalAttributes, string classNames) + { + if (additionalAttributes is null || !additionalAttributes.TryGetValue("class", out var @class)) + { + return classNames; + } + + var classAttributeValue = Convert.ToString(@class, CultureInfo.InvariantCulture); + + if (string.IsNullOrEmpty(classAttributeValue)) + { + return classNames; + } + + if (string.IsNullOrEmpty(classNames)) + { + return classAttributeValue; + } + + return $"{classAttributeValue} {classNames}"; + } } } From f01b491d23bba78380adb4d7f0b713bfae4a878e Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 11:17:21 +0200 Subject: [PATCH 14/28] Revert SetParametersAsync logic --- src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs index f3238482f7..7e26f756ad 100644 --- a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs +++ b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs @@ -12,7 +12,6 @@ namespace Microsoft.Fast.Components.FluentUI public abstract class FluentInputBase : ComponentBase, IDisposable { private readonly EventHandler _validationStateChangedHandler; - private bool _hasInitializedParameters; private bool _previousParsingAttemptFailed; private ValidationMessageStore? _parsingValidationMessages; private Type? _nullableUnderlyingType; @@ -184,7 +183,7 @@ public override Task SetParametersAsync(ParameterView parameters) { parameters.SetParameterProperties(this); - if (!_hasInitializedParameters) + if (EditContext != null || CascadedEditContext != null) { // This is the first run // Could put this logic in OnInit, but its nice to avoid forcing people who override OnInit to call base.OnInit() @@ -204,7 +203,6 @@ public override Task SetParametersAsync(ParameterView parameters) } _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue)); - _hasInitializedParameters = true; } else if (CascadedEditContext != EditContext) { From 212e431ab18ef9cde58c688c763eb106aa36cd6e Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 12:55:43 +0200 Subject: [PATCH 15/28] Move RTL/Theme switches to webcomponents page --- .../Components/FluentSwitchTest.razor | 22 ------------------- .../Pages/Webcomponents.razor | 16 ++++++++++++++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/examples/FluentUIServerSample/Components/FluentSwitchTest.razor b/examples/FluentUIServerSample/Components/FluentSwitchTest.razor index 402fbf13e8..7d320a1b9d 100644 --- a/examples/FluentUIServerSample/Components/FluentSwitchTest.razor +++ b/examples/FluentUIServerSample/Components/FluentSwitchTest.razor @@ -1,25 +1,3 @@ -
- - - Direction - ltr - rtl - - - - Theme - Dark - Light - -

Switch

Default

diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 67ec307e07..815c72f6a4 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -118,6 +118,22 @@
+
+ + + Direction + ltr + rtl + + + + Theme + Dark + Light + +
@switch (Target) { case "Accordion": From fd775b72547987ca8d342608be61cabce4367043 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 29 Sep 2021 13:52:58 +0200 Subject: [PATCH 16/28] Enable Hot Reload Make Theme switch work --- .../Pages/Webcomponents.razor | 99 ++++++++++--------- .../Properties/launchSettings.json | 4 +- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 815c72f6a4..205af48ce2 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -1,5 +1,55 @@ @page "/webcomponents/{Target?}" + + + @using FluentUIServerSample.Components + +

Fluent components test page

@@ -128,7 +178,7 @@ rtl - + Theme Dark Light @@ -253,50 +303,11 @@ }
+ - @code{ diff --git a/examples/FluentUIServerSample/Properties/launchSettings.json b/examples/FluentUIServerSample/Properties/launchSettings.json index 572143dbe9..632be8cfb7 100644 --- a/examples/FluentUIServerSample/Properties/launchSettings.json +++ b/examples/FluentUIServerSample/Properties/launchSettings.json @@ -13,12 +13,14 @@ "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "hotReloadProfile": "aspnetcore" }, "FluentUIServerSample": { "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": true, + "hotReloadProfile": "aspnetcore", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" From 49372e016d414c7fa920f3627586148ed8366de0 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 00:02:15 +0200 Subject: [PATCH 17/28] Fix compiler warnings/messages --- examples/FluentUIServerSample/Pages/Webcomponents.razor | 6 +++--- src/Microsoft.Fast.Components.FluentUI/Appearance.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs | 4 ++-- src/Microsoft.Fast.Components.FluentUI/Color.cs | 4 ++-- .../Components/FluentDesignSystemProvider.razor | 4 ++-- src/Microsoft.Fast.Components.FluentUI/DataGridCellType.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/DataGridRowType.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/Direction.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs | 2 +- .../GenerateHeaderOptions.cs | 6 +++--- .../HorizontalPosition.cs | 6 +++--- .../LocalizationDirection.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/Orientation.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/Positioning.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/Resize.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/Scaling.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/Shape.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs | 2 +- src/Microsoft.Fast.Components.FluentUI/TooltipPosition.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/UpdateMode.cs | 6 +++--- src/Microsoft.Fast.Components.FluentUI/VerticalPosition.cs | 6 +++--- 21 files changed, 46 insertions(+), 46 deletions(-) diff --git a/examples/FluentUIServerSample/Pages/Webcomponents.razor b/examples/FluentUIServerSample/Pages/Webcomponents.razor index 7ee85eda74..129cd4c22b 100644 --- a/examples/FluentUIServerSample/Pages/Webcomponents.razor +++ b/examples/FluentUIServerSample/Pages/Webcomponents.razor @@ -51,7 +51,7 @@
- +

Fluent components test page

  • @@ -168,7 +168,7 @@
-
+
@@ -178,7 +178,7 @@ rtl - + Theme Dark Light diff --git a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs index 1b3ffe1f0c..fb9406db33 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Appearance.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Appearance.cs @@ -17,7 +17,7 @@ public enum Appearance internal static class AppearanceExtensions { - private static Dictionary _appearanceValues = + private static readonly Dictionary _appearanceValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Appearance? value) => value == null ? null : _appearanceValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs index 60ba4e83b5..0dedbfd4da 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Autocomplete.cs @@ -13,7 +13,7 @@ public enum Autocomplete internal static class AutocompleteExtensions { - private static Dictionary _autocompleteValues = + private static readonly Dictionary _autocompleteValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Autocomplete? value) => value == null ? null : _autocompleteValues[value.Value]; @@ -27,7 +27,7 @@ public enum Position internal static class PositionExtensions { - private static Dictionary _positionValues = + private static readonly Dictionary _positionValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Position? value) => value == null ? null : _positionValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/Color.cs b/src/Microsoft.Fast.Components.FluentUI/Color.cs index 4ea51e596f..b93b7093f7 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Color.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Color.cs @@ -12,7 +12,7 @@ public enum Color internal static class ColorExtensions { - private static Dictionary _colorValues = + private static readonly Dictionary _colorValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Color? value) => value == null ? null : _colorValues[value.Value]; @@ -26,7 +26,7 @@ public enum Fill internal static class FillExtensions { - private static Dictionary _fillValues = + private static readonly Dictionary _fillValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Fill? value) => value == null ? null : _fillValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDesignSystemProvider.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDesignSystemProvider.razor index 4f00f555a2..191cb39d03 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDesignSystemProvider.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDesignSystemProvider.razor @@ -128,6 +128,6 @@ [Parameter] public int? NeutralStrokeFocusDelta { get; set; } [Parameter] public float? BaseLayerLuminance { get; set; } - [Parameter] public RenderFragment ChildContent { get; set; } - [Parameter(CaptureUnmatchedValues = true)] public IDictionary AdditionalAttributes { get; set; } + [Parameter] public RenderFragment? ChildContent { get; set; } + [Parameter(CaptureUnmatchedValues = true)] public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/DataGridCellType.cs b/src/Microsoft.Fast.Components.FluentUI/DataGridCellType.cs index 48a4669cd2..b7f9aa64fd 100644 --- a/src/Microsoft.Fast.Components.FluentUI/DataGridCellType.cs +++ b/src/Microsoft.Fast.Components.FluentUI/DataGridCellType.cs @@ -13,9 +13,9 @@ public enum DataGridCellType internal static class CellTypeExtensions { - private static Dictionary _cellTypeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _cellTypeValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this DataGridCellType? value) => value == null ? null : _cellTypeValues[value.Value]; + public static string? ToAttributeValue(this DataGridCellType? value) => value == null ? null : _cellTypeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/DataGridRowType.cs b/src/Microsoft.Fast.Components.FluentUI/DataGridRowType.cs index 512f4f2650..4e09fe2889 100644 --- a/src/Microsoft.Fast.Components.FluentUI/DataGridRowType.cs +++ b/src/Microsoft.Fast.Components.FluentUI/DataGridRowType.cs @@ -14,9 +14,9 @@ public enum DataGridRowType internal static class DataGridRowTypeExtensions { - private static Dictionary _dataGridRowTypeValues = - Enum.GetValues().ToDictionary(id => id, id => string.Join("-", Regex.Split(Enum.GetName(id), @"(? _dataGridRowTypeValues = + Enum.GetValues().ToDictionary(id => id, id => string.Join("-", Regex.Split(Enum.GetName(id)!, @"(? value == null ? null : _dataGridRowTypeValues[value.Value]; + public static string? ToAttributeValue(this DataGridRowType? value) => value == null ? null : _dataGridRowTypeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Direction.cs b/src/Microsoft.Fast.Components.FluentUI/Direction.cs index 76cded635a..39f8a4d1a4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Direction.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Direction.cs @@ -12,7 +12,7 @@ public enum Direction internal static class DirectionExtensions { - private static Dictionary _directionValues = + private static readonly Dictionary _directionValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Direction? value) => value == null ? null : _directionValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs index f339d2f8bd..32de7d82dd 100644 --- a/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs +++ b/src/Microsoft.Fast.Components.FluentUI/ExpandMode.cs @@ -11,7 +11,7 @@ public enum ExpandMode internal static class ExpandModeExtensions { - private static Dictionary _expandModeValues = + private static readonly Dictionary _expandModeValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this ExpandMode? value) => value == null ? null : _expandModeValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/GenerateHeaderOptions.cs b/src/Microsoft.Fast.Components.FluentUI/GenerateHeaderOptions.cs index ade40d4636..441ce7fd07 100644 --- a/src/Microsoft.Fast.Components.FluentUI/GenerateHeaderOptions.cs +++ b/src/Microsoft.Fast.Components.FluentUI/GenerateHeaderOptions.cs @@ -13,9 +13,9 @@ public enum GenerateHeaderOptions internal static class GenerateHeaderExtensions { - private static Dictionary _generateHeaderValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _generateHeaderValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this GenerateHeaderOptions? value) => value == null ? null : _generateHeaderValues[value.Value]; + public static string? ToAttributeValue(this GenerateHeaderOptions? value) => value == null ? null : _generateHeaderValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/HorizontalPosition.cs b/src/Microsoft.Fast.Components.FluentUI/HorizontalPosition.cs index beeb3906da..cf22efe2e5 100644 --- a/src/Microsoft.Fast.Components.FluentUI/HorizontalPosition.cs +++ b/src/Microsoft.Fast.Components.FluentUI/HorizontalPosition.cs @@ -15,9 +15,9 @@ public enum HorizontalPosition internal static class HorizontalDefaultPositionExtensions { - private static Dictionary _positionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _positionValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this HorizontalPosition? value) => value == null ? null : _positionValues[value.Value]; + public static string? ToAttributeValue(this HorizontalPosition? value) => value == null ? null : _positionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/LocalizationDirection.cs b/src/Microsoft.Fast.Components.FluentUI/LocalizationDirection.cs index 2436f88e01..238cb6105b 100644 --- a/src/Microsoft.Fast.Components.FluentUI/LocalizationDirection.cs +++ b/src/Microsoft.Fast.Components.FluentUI/LocalizationDirection.cs @@ -13,9 +13,9 @@ public enum LocalizationDirection internal static class LocalizationDirectionExtensions { - private static Dictionary _directionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _directionValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this LocalizationDirection? value) => value == null ? null : _directionValues[value.Value]; + public static string? ToAttributeValue(this LocalizationDirection? value) => value == null ? null : _directionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs index 22b9bea07c..7c1cd1bce8 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Orientation.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Orientation.cs @@ -12,7 +12,7 @@ public enum Orientation internal static class OrientationExtensions { - private static Dictionary _orientationValues = + private static readonly Dictionary _orientationValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Orientation? value) => value == null ? null : _orientationValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/Positioning.cs b/src/Microsoft.Fast.Components.FluentUI/Positioning.cs index 52ebbfbf05..fbcda7d7d6 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Positioning.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Positioning.cs @@ -13,9 +13,9 @@ public enum Positioning internal static class PositioningExtensions { - private static Dictionary _positioningValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _positioningValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Positioning? value) => value == null ? null : _positioningValues[value.Value]; + public static string? ToAttributeValue(this Positioning? value) => value == null ? null : _positioningValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Resize.cs b/src/Microsoft.Fast.Components.FluentUI/Resize.cs index 1bb969303c..445dafcaeb 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Resize.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Resize.cs @@ -13,7 +13,7 @@ public enum Resize internal static class ResizeExtensions { - private static Dictionary _resizeValues = + private static readonly Dictionary _resizeValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Resize? value) => value == null ? null : _resizeValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/Scaling.cs b/src/Microsoft.Fast.Components.FluentUI/Scaling.cs index fbbf38beae..3b65d4e5de 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Scaling.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Scaling.cs @@ -13,9 +13,9 @@ public enum Scaling internal static class ScalingExtensions { - private static Dictionary _scalingValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _scalingValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this Scaling? value) => value == null ? null : _scalingValues[value.Value]; + public static string? ToAttributeValue(this Scaling? value) => value == null ? null : _scalingValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Shape.cs b/src/Microsoft.Fast.Components.FluentUI/Shape.cs index be8e188807..eabbee155b 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Shape.cs +++ b/src/Microsoft.Fast.Components.FluentUI/Shape.cs @@ -12,7 +12,7 @@ public enum Shape internal static class ShapeExtensions { - private static Dictionary _orientationValues = + private static readonly Dictionary _orientationValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this Shape? value) => value == null ? null : _orientationValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs index bf97038620..c024fb7072 100644 --- a/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs +++ b/src/Microsoft.Fast.Components.FluentUI/TextFieldType.cs @@ -15,7 +15,7 @@ public enum TextFieldType internal static class TextFieldTypeExtensions { - private static Dictionary _textFieldTypeValues = + private static readonly Dictionary _textFieldTypeValues = Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); public static string? ToAttributeValue(this TextFieldType? value) => value == null ? null : _textFieldTypeValues[value.Value]; diff --git a/src/Microsoft.Fast.Components.FluentUI/TooltipPosition.cs b/src/Microsoft.Fast.Components.FluentUI/TooltipPosition.cs index 584df27c68..af63b7b0d4 100644 --- a/src/Microsoft.Fast.Components.FluentUI/TooltipPosition.cs +++ b/src/Microsoft.Fast.Components.FluentUI/TooltipPosition.cs @@ -16,9 +16,9 @@ public enum TooltipPosition internal static class TooltipPositionExtensions { - private static Dictionary _tooltipPositionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _tooltipPositionValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this TooltipPosition? value) => value == null ? null : _tooltipPositionValues[value.Value]; + public static string? ToAttributeValue(this TooltipPosition? value) => value == null ? null : _tooltipPositionValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/UpdateMode.cs b/src/Microsoft.Fast.Components.FluentUI/UpdateMode.cs index 7c7e40e7b6..07b2427ce7 100644 --- a/src/Microsoft.Fast.Components.FluentUI/UpdateMode.cs +++ b/src/Microsoft.Fast.Components.FluentUI/UpdateMode.cs @@ -12,9 +12,9 @@ public enum UpdateMode internal static class UpdateModeExtensions { - private static Dictionary _updateModeValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _updateModeValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this UpdateMode? value) => value == null ? null : _updateModeValues[value.Value]; + public static string? ToAttributeValue(this UpdateMode? value) => value == null ? null : _updateModeValues[value.Value]; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/VerticalPosition.cs b/src/Microsoft.Fast.Components.FluentUI/VerticalPosition.cs index ab4b7a3d6a..64a8cdd40d 100644 --- a/src/Microsoft.Fast.Components.FluentUI/VerticalPosition.cs +++ b/src/Microsoft.Fast.Components.FluentUI/VerticalPosition.cs @@ -13,9 +13,9 @@ public enum VerticalPosition internal static class VerticalDefaultPositionExtensions { - private static Dictionary _positionValues = - Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id).ToLowerInvariant()); + private static readonly Dictionary _positionValues = + Enum.GetValues().ToDictionary(id => id, id => Enum.GetName(id)!.ToLowerInvariant()); - public static string ToAttributeValue(this VerticalPosition? value) => value == null ? null : _positionValues[value.Value]; + public static string? ToAttributeValue(this VerticalPosition? value) => value == null ? null : _positionValues[value.Value]; } } From 5b545c0503d72d3cfa8bef83df3552d9085e7009 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 15:33:01 +0200 Subject: [PATCH 18/28] Change CI validation to use .NET 6 (prerelease) --- .github/workflows/ci-daily.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-daily.yml b/.github/workflows/ci-daily.yml index fc1f372af6..c45af75924 100644 --- a/.github/workflows/ci-daily.yml +++ b/.github/workflows/ci-daily.yml @@ -16,7 +16,8 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x + include-prerelease: true - name: Restore dependencies run: dotnet restore - name: Build From 2b674d96721cd0629155352d38b4e3dbdb35951c Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 15:37:15 +0200 Subject: [PATCH 19/28] Add link to Fluent UI sample site --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c01867b0f2..2649a00041 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The `Microsoft.Fast.Components.FluentUI` package provides a lightweight set of [Blazor](https://blazor.net) component wrappers around Microsoft's official FluentUI Web Components. The FluentUI Web Components are built on [FAST](https://www.fast.design/) and work in every major browser. To get up and running with `Microsoft.Fast.Components.FluentUI` see the Getting Started section below. -The source for `@fluentui/web-components` is hosted in [the Fluent UI monorepo](https://github.com/microsoft/fluentui/tree/master/packages/web-components). +The source for `@fluentui/web-components` is hosted in [the Fluent UI monorepo](https://github.com/microsoft/fluentui/tree/master/packages/web-components). An implementation of all the current Fluent Web Components can be found at https://aka.ms/fluentwebcomponents. ## Getting Started From f116db41c5cd7f3a3068c4ce2c28e9dcd6062c2c Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 15:41:32 +0200 Subject: [PATCH 20/28] Update CI Validation workflow to net 6 branch --- .github/workflows/ci-daily.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-daily.yml b/.github/workflows/ci-daily.yml index c45af75924..5dbe146e97 100644 --- a/.github/workflows/ci-daily.yml +++ b/.github/workflows/ci-daily.yml @@ -2,9 +2,9 @@ name: CI - Validation for Blazor / FluentUI on: push: - branches: [ main ] + branches: [ net6 ] pull_request: - branches: [ main ] + branches: [ net6 ] jobs: build: From 0ed4cb0940941d338c0299fd2677cbf737e2a79d Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 15:51:17 +0200 Subject: [PATCH 21/28] Nullable work --- .../Components/FluentAnchoredRegion.razor | 8 ++++---- .../Components/FluentDataGrid.razor | 11 ++++++----- .../Components/FluentDataGridCell.razor | 4 ++-- .../Components/FluentDataGridRow.razor | 10 +++++----- .../Components/FluentHorizontalScroll.razor | 4 ++-- .../Components/FluentToolbar.razor | 4 ++-- .../Components/FluentTooltip.razor | 4 ++-- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchoredRegion.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchoredRegion.razor index a316440c9a..18fab83675 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchoredRegion.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentAnchoredRegion.razor @@ -21,13 +21,13 @@ /// The html id of the HTMLElement used as the anchor around which the positioning region is placed. This must be set for the component's positioning logic to be active. /// [Parameter] - public string Anchor { get; set; } + public string? Anchor { get; set; } /// /// The ID of the HTMLElement to be used as the viewport used to determine available layout space around the anchor element. If unset the parent element of the anchored region is used. /// [Parameter] - public string Viewport { get; set; } + public string? Viewport { get; set; } /// /// Default is 'uncontrolled'. @@ -96,8 +96,8 @@ public UpdateMode? AutoUpdateMode { get; set; } = UpdateMode.Anchor; [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor index 0d4af53db1..6ac262b852 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor @@ -11,7 +11,7 @@ @{ int gridColumn = 1; - foreach (ColumnDefinition column in ColumnDefinitions) + foreach (ColumnDefinition column in ColumnDefinitions!) { @if (HeaderCellTemplate != null) @@ -60,10 +60,11 @@ //FAST Properties [Parameter] - public List RowsData { get; set; } + public List? RowsData { get; set; } [Parameter] - public IEnumerable> ColumnDefinitions { get; set; } + [EditorRequired] + public IEnumerable>? ColumnDefinitions { get; set; } [Parameter] public RenderFragment>? HeaderCellTemplate { get; set; } = null; @@ -73,11 +74,11 @@ // General Blazor parameters [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridCell.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridCell.razor index 6f0e05fd4b..550c781b44 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridCell.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridCell.razor @@ -15,8 +15,8 @@ // General Blazor parameters [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridRow.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridRow.razor index b935ef76ca..fcb5234f1a 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridRow.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGridRow.razor @@ -5,8 +5,8 @@ @attributes="@AdditionalAttributes"> @for(int index=0; index column = ColumnDefinitions?.ElementAt(index); - @(column.FieldSelector!(RowData)?.ToString()) + ColumnDefinition column = ColumnDefinitions!.ElementAt(index); + @(column.FieldSelector!(RowData!)?.ToString()) } @ChildContent @@ -24,15 +24,15 @@ // FAST Properties [Parameter] - public TItem RowData { get; set; } + public TItem? RowData { get; set; } [Parameter] public IEnumerable>? ColumnDefinitions { get; set; } // General Blazor parameters [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentHorizontalScroll.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentHorizontalScroll.razor index 1705551c47..20b10b7c83 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentHorizontalScroll.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentHorizontalScroll.razor @@ -19,8 +19,8 @@ public string? Easing { get; set; } [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentToolbar.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentToolbar.razor index 5804c0fe85..2e9df4c685 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentToolbar.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentToolbar.razor @@ -7,8 +7,8 @@ public Orientation? Orientation { get; set; } = FluentUI.Orientation.Horizontal; [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTooltip.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTooltip.razor index fefe2e0496..6775a5194e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentTooltip.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentTooltip.razor @@ -27,8 +27,8 @@ public bool? VerticalViewportLock { get; set; } = false; [Parameter] - public RenderFragment ChildContent { get; set; } + public RenderFragment? ChildContent { get; set; } [Parameter(CaptureUnmatchedValues = true)] - public IDictionary AdditionalAttributes { get; set; } + public IDictionary? AdditionalAttributes { get; set; } } \ No newline at end of file From 02dc9183db871b64b0834376b66b6b118f973516 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Wed, 6 Oct 2021 16:10:09 +0200 Subject: [PATCH 22/28] Nullable work --- .../Components/FluentDataGridTest.razor | 28 +++++++++---------- .../Components/FluentDataGrid.razor | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/examples/FluentUIServerSample/Components/FluentDataGridTest.razor b/examples/FluentUIServerSample/Components/FluentDataGridTest.razor index d1ed6e8671..e583cb9041 100644 --- a/examples/FluentUIServerSample/Components/FluentDataGridTest.razor +++ b/examples/FluentUIServerSample/Components/FluentDataGridTest.razor @@ -39,10 +39,10 @@ SortColumn(context))> - @context.Title + @context.Title @if (context.Title == lastSortColumn?.Title) { - @(isAscending ? " ↑" : " ↓") + @(isAscending ? " ↑" : " ↓") } @@ -73,13 +73,13 @@ private bool isAscending = false; public string filterValue = ""; - List RowsGrid1 = new List() + List RowsGrid1 = new() { new SampleGrid1Data("Rob", 19 ), new SampleGrid1Data("Bob", 20 ) }; - List RowsGrid2 = new List() + List RowsGrid2 = new() { new SampleGrid2Data("value 1-1", "value 2-1", "value 3-1", "value 4-1" ), new SampleGrid2Data("value 1-2", "value 2-2", "value 3-2", "value 4-2" ), @@ -87,7 +87,7 @@ new SampleGrid2Data("value 1-4", "value 2-4", "value 3-4", "value 4-4" ) }; - + List RawSortedRowsGrid = new List() { new SampleGrid3Data("apples", "$1.50", "red" ), @@ -96,7 +96,7 @@ new SampleGrid3Data("oranges", "$1.25", "orange" ) }; - List SortedRowsGrid; + List SortedRowsGrid = new(); protected override void OnInitialized() @@ -112,7 +112,7 @@ SortingColumnsGrid.Add(new ColumnDefinition("Fruit", x => x.fruit)); SortingColumnsGrid.Add(new ColumnDefinition("Cost", x => x.cost)); SortingColumnsGrid.Add(new ColumnDefinition("Color", x => x.color)); - + SortedRowsGrid = RawSortedRowsGrid; base.OnInitialized(); @@ -121,7 +121,7 @@ private void FilterChanged(ChangeEventArgs args) { var filter = args.Value as string; - + if (string.IsNullOrWhiteSpace(filter)) { SortedRowsGrid = RawSortedRowsGrid; @@ -132,9 +132,9 @@ } if (lastSortColumn != null) { - SortedRowsGrid.Sort(new CustomComparer(lastSortColumn.FieldSelector, isAscending)); + SortedRowsGrid.Sort(new CustomComparer(lastSortColumn.FieldSelector!, isAscending)); } - + } private void SortColumn(ColumnDefinition columnDefinition) @@ -148,7 +148,7 @@ lastSortColumn = columnDefinition; isAscending = true; } - SortedRowsGrid.Sort(new CustomComparer(columnDefinition.FieldSelector, isAscending)); + SortedRowsGrid.Sort(new CustomComparer(columnDefinition.FieldSelector!, isAscending)); } class CustomComparer : IComparer @@ -162,10 +162,10 @@ _isAscending = isAscending; } - int IComparer.Compare(SampleGrid3Data x, SampleGrid3Data y) + int IComparer.Compare(SampleGrid3Data? x, SampleGrid3Data? y) { - var xs = _selector(x) as string; - var ys = _selector(y) as string; + var xs = _selector(x!) as string; + var ys = _selector(y!) as string; if (xs == null || ys == null) return 0; return string.Compare(xs, ys) * (_isAscending ? 1 : -1); diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor index 6ac262b852..f4d687073e 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentDataGrid.razor @@ -63,7 +63,6 @@ public List? RowsData { get; set; } [Parameter] - [EditorRequired] public IEnumerable>? ColumnDefinitions { get; set; } [Parameter] From cd1acb3ce64a74df8cef8a9a9fdbed1296c101db Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Mon, 11 Oct 2021 16:06:48 +0200 Subject: [PATCH 23/28] chore: prepare 0.5.0 release --- .../Microsoft.Fast.Components.FluentUI.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index 041605afe2..aec9e0a4df 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -14,8 +14,8 @@ Microsoft Fluent UI Components Library for Blazor on FAST Authored by the Microsoft FAST team. true - 0.3.0 - 0.3.0 + 0.5.0 + 0.5.0 false enable From 9ed89e685890a4b3f6c3b7e9cccfc03b2f8e41ae Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Tue, 12 Oct 2021 22:49:23 +0200 Subject: [PATCH 24/28] Update to rc2 --- .../Microsoft.Fast.Components.FluentUI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj index aec9e0a4df..d4d629ab06 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj +++ b/src/Microsoft.Fast.Components.FluentUI/Microsoft.Fast.Components.FluentUI.csproj @@ -37,7 +37,7 @@ - + From a13e67e7e2dea2faf999068329a46d81b9653a77 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Thu, 21 Oct 2021 12:01:25 +0200 Subject: [PATCH 25/28] Reverted ci-daily back to main branch --- .github/workflows/ci-daily.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-daily.yml b/.github/workflows/ci-daily.yml index 5dbe146e97..c45af75924 100644 --- a/.github/workflows/ci-daily.yml +++ b/.github/workflows/ci-daily.yml @@ -2,9 +2,9 @@ name: CI - Validation for Blazor / FluentUI on: push: - branches: [ net6 ] + branches: [ main ] pull_request: - branches: [ net6 ] + branches: [ main ] jobs: build: From 479daa4d6766cdb45db7ba5334767e5df0f67d11 Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Sat, 23 Oct 2021 16:51:49 +0200 Subject: [PATCH 26/28] Fix DataGridTest --- .../FluentUIServerSample/Components/FluentDataGridTest.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/FluentUIServerSample/Components/FluentDataGridTest.razor b/examples/FluentUIServerSample/Components/FluentDataGridTest.razor index e583cb9041..6a65caa303 100644 --- a/examples/FluentUIServerSample/Components/FluentDataGridTest.razor +++ b/examples/FluentUIServerSample/Components/FluentDataGridTest.razor @@ -36,7 +36,7 @@

Sorting/Filtering grid

Filter Fruit - + SortColumn(context))> @context.Title From b8f21f29f64ba316b014fdca41868feb9ff4f7bb Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Sat, 23 Oct 2021 17:55:09 +0200 Subject: [PATCH 27/28] Fix FluentNumberField binding --- .../Components/FluentNumberField.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor index ac766884ee..4f205eac50 100644 --- a/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor +++ b/src/Microsoft.Fast.Components.FluentUI/Components/FluentNumberField.razor @@ -12,7 +12,7 @@ maxlength="@MaxLength" minlength="@MinLength" size="@Size" - change="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" + @onchange="@(EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, CurrentValueAsString))" readonly="@Readonly" disabled="@Disabled" required="@Required" From cd05c7f1213ab2615b3fe39d60677b053007983f Mon Sep 17 00:00:00 2001 From: Vincent Baaij Date: Mon, 25 Oct 2021 22:59:50 +0200 Subject: [PATCH 28/28] Remove commented code --- .../FluentInputBase.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs index 7e26f756ad..d9a7e84ffc 100644 --- a/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs +++ b/src/Microsoft.Fast.Components.FluentUI/FluentInputBase.cs @@ -1,12 +1,13 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; + +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; namespace Microsoft.Fast.Components.FluentUI { public abstract class FluentInputBase : ComponentBase, IDisposable @@ -85,17 +86,6 @@ protected string? CurrentValueAsString get => FormatValueAsString(CurrentValue); set { - //if (EditContext == null) - //{ - // if (TryParseValueFromString(value, out var parsedValue, out var _)) - // { - // CurrentValue = parsedValue; - // } - - // // If we are not in the context of an edit form, don't do anything with the current value. - // return; - //} - _parsingValidationMessages?.Clear(); bool parsingFailed;