diff --git a/src/MudBlazor.Docs.Compiler/DocStrings.cs b/src/MudBlazor.Docs.Compiler/DocStrings.cs index d7514a6f987d..e772872777cf 100644 --- a/src/MudBlazor.Docs.Compiler/DocStrings.cs +++ b/src/MudBlazor.Docs.Compiler/DocStrings.cs @@ -102,7 +102,7 @@ private static string convertSeeTags(string doc) { return SeeCrefRegularExpression().Replace(doc, match => { - string result = match.Groups[2].Value; // get the name of Type or type member (Field, Property, Method, or Event) + var result = match.Groups[2].Value; // get the name of Type or type member (Field, Property, Method, or Event) result = BacktickRegularExpression().Replace(result, ""); // remove `1 from generic type name return result; }); diff --git a/src/MudBlazor.Docs.Compiler/TestsForApiPages.cs b/src/MudBlazor.Docs.Compiler/TestsForApiPages.cs index 48c585b9e65d..ec6fc07dafac 100644 --- a/src/MudBlazor.Docs.Compiler/TestsForApiPages.cs +++ b/src/MudBlazor.Docs.Compiler/TestsForApiPages.cs @@ -85,7 +85,7 @@ public static bool IsObsolete(Type type) { var attributes = (ObsoleteAttribute[]) type.GetCustomAttributes(typeof(ObsoleteAttribute), false); - return (attributes != null && attributes.Length > 0); + return attributes != null && attributes.Length > 0; } private static string SafeTypeName(Type type, bool removeT = false) diff --git a/src/MudBlazor.Docs.Compiler/XmlDocumentation.cs b/src/MudBlazor.Docs.Compiler/XmlDocumentation.cs index 0b4063faee31..2e5b31de4a7b 100644 --- a/src/MudBlazor.Docs.Compiler/XmlDocumentation.cs +++ b/src/MudBlazor.Docs.Compiler/XmlDocumentation.cs @@ -499,7 +499,7 @@ public static string GetDocumentation(this EventInfo eventInfo) public static string XmlDocumentationKeyHelper(string typeFullNameString, string memberNameString) { var key = DocumentationKeyRegularExpression().Replace(typeFullNameString, string.Empty).Replace('+', '.'); - if (!(memberNameString is null)) + if (memberNameString is not null) { key += "." + memberNameString; } @@ -562,7 +562,7 @@ public static string GetDocumentation(this MemberInfo memberInfo) public static string GetDocumentation(this ParameterInfo parameterInfo) { var memberDocumentation = parameterInfo.Member.GetDocumentation(); - if (!(memberDocumentation is null)) + if (memberDocumentation is not null) { var regexPattern = Regex.Escape(@"") + diff --git a/src/MudBlazor.Docs.WasmHost/Controllers/AmericanStatesController.cs b/src/MudBlazor.Docs.WasmHost/Controllers/AmericanStatesController.cs index e0a64ad94e4b..e5bfea461f3e 100644 --- a/src/MudBlazor.Docs.WasmHost/Controllers/AmericanStatesController.cs +++ b/src/MudBlazor.Docs.WasmHost/Controllers/AmericanStatesController.cs @@ -35,7 +35,7 @@ public async Task SearchWithDelay(CancellationToken cancellationT List result = new(); foreach (var item in states) { - if (string.IsNullOrEmpty(input) == true || item.Contains(input, StringComparison.InvariantCultureIgnoreCase)) + if (string.IsNullOrEmpty(input) || item.Contains(input, StringComparison.InvariantCultureIgnoreCase)) { result.Add(item); } diff --git a/src/MudBlazor.Docs.WasmHost/Prerender/ICrawlerIdentifier.cs b/src/MudBlazor.Docs.WasmHost/Prerender/ICrawlerIdentifier.cs index d3a97b66bd5c..06040795b084 100644 --- a/src/MudBlazor.Docs.WasmHost/Prerender/ICrawlerIdentifier.cs +++ b/src/MudBlazor.Docs.WasmHost/Prerender/ICrawlerIdentifier.cs @@ -22,7 +22,7 @@ public interface ICrawlerIdentifier public class FileBasedCrawlerIdentifier : ICrawlerIdentifier { - private record CrawlerEntry(string Pattern, string Url, IEnumerable Instances); + private record CrawlerEntry(string Pattern, string Url, IEnumerable Instances); private readonly string _filename; private LimitedConcurrentDictionary _cache = new(1_000); @@ -49,11 +49,11 @@ public Task IsRequestByCrawler(HttpContext context) if (userAgentHeader.Any() == false) { return Task.FromResult(false); } var value = userAgentHeader.First(); - if (_cache.ContainsKey(value) == true) { return Task.FromResult(_cache[value]); } + if (_cache.ContainsKey(value)) { return Task.FromResult(_cache[value]); } foreach (var item in _patterns) { - if (item.IsMatch(value) == true) + if (item.IsMatch(value)) { _cache.TryAdd(value, true); return Task.FromResult(true); diff --git a/src/MudBlazor.Docs.WasmHost/Prerender/LimitedConcurrentDictionary.cs b/src/MudBlazor.Docs.WasmHost/Prerender/LimitedConcurrentDictionary.cs index 1e60c0534908..41b4628e8290 100644 --- a/src/MudBlazor.Docs.WasmHost/Prerender/LimitedConcurrentDictionary.cs +++ b/src/MudBlazor.Docs.WasmHost/Prerender/LimitedConcurrentDictionary.cs @@ -11,9 +11,9 @@ namespace MudBlazor.Docs.WasmHost.Prerender public class LimitedConcurrentDictionary { private ConcurrentDictionary _dict = new(); - private Int32 MaxCapacity { get; init; } + private int MaxCapacity { get; init; } - public LimitedConcurrentDictionary(Int32 maxCapacity) + public LimitedConcurrentDictionary(int maxCapacity) { MaxCapacity = maxCapacity; } diff --git a/src/MudBlazor.Docs.WasmHost/Prerender/PrerenderMiddleware.cs b/src/MudBlazor.Docs.WasmHost/Prerender/PrerenderMiddleware.cs index 2f3bf45fa177..fcb263723c4d 100644 --- a/src/MudBlazor.Docs.WasmHost/Prerender/PrerenderMiddleware.cs +++ b/src/MudBlazor.Docs.WasmHost/Prerender/PrerenderMiddleware.cs @@ -25,7 +25,7 @@ public PrerenderMiddleware(RequestDelegate next, ICrawlerIdentifier crawlerIdent public async Task Invoke(HttpContext context) { var path = context.Request.Path.ToString().ToLower(); - if (path.Contains("webapi") == true) + if (path.Contains("webapi")) { await _next(context); return; @@ -38,7 +38,7 @@ public async Task Invoke(HttpContext context) } else { - if (_responseCache.ContainsKey(path) == true) + if (_responseCache.ContainsKey(path)) { context.Response.StatusCode = 200; context.Response.ContentType = "text/html; charset=utf-8"; diff --git a/src/MudBlazor.Docs/Components/LandingPage/CalculatorApp/Expression.cs b/src/MudBlazor.Docs/Components/LandingPage/CalculatorApp/Expression.cs index a081e1067fc3..579e405aac08 100644 --- a/src/MudBlazor.Docs/Components/LandingPage/CalculatorApp/Expression.cs +++ b/src/MudBlazor.Docs/Components/LandingPage/CalculatorApp/Expression.cs @@ -42,7 +42,7 @@ public Expression(string expression) public Expression(SimpleParser parser) { - this._parser = parser; + _parser = parser; } public Expression(double nr) diff --git a/src/MudBlazor.Docs/Components/SectionContent.razor.cs b/src/MudBlazor.Docs/Components/SectionContent.razor.cs index b075fbbb3247..fdf8d5070ccb 100644 --- a/src/MudBlazor.Docs/Components/SectionContent.razor.cs +++ b/src/MudBlazor.Docs/Components/SectionContent.razor.cs @@ -147,7 +147,7 @@ RenderFragment CodeComponent(string code) => builder => protected virtual async void RunOnTryMudBlazor() { - string firstFile = ""; + var firstFile = ""; if (Codes != null) { diff --git a/src/MudBlazor.Docs/Extensions/MethodInfoExtensions.cs b/src/MudBlazor.Docs/Extensions/MethodInfoExtensions.cs index c232c65bbeb4..46946131572e 100644 --- a/src/MudBlazor.Docs/Extensions/MethodInfoExtensions.cs +++ b/src/MudBlazor.Docs/Extensions/MethodInfoExtensions.cs @@ -72,7 +72,7 @@ public static string GetSignature(this MethodInfo method, bool callable = false) stringBuilder.Append("this "); } } - else if (secondParameter == true) + else if (secondParameter) { secondParameter = false; } diff --git a/src/MudBlazor.Docs/Models/XmlDocumentation.cs b/src/MudBlazor.Docs/Models/XmlDocumentation.cs index 19aa77eec71f..4a1f60d80ac8 100644 --- a/src/MudBlazor.Docs/Models/XmlDocumentation.cs +++ b/src/MudBlazor.Docs/Models/XmlDocumentation.cs @@ -508,7 +508,7 @@ public static string GetDocumentation(this EventInfo eventInfo) public static string XmlDocumentationKeyHelper(string typeFullNameString, string memberNameString) { var key = DocumentationKeyRegularExpression().Replace(typeFullNameString, string.Empty).Replace('+', '.'); - if (!(memberNameString is null)) + if (memberNameString is not null) { key += "." + memberNameString; } @@ -571,7 +571,7 @@ public static string GetDocumentation(this MemberInfo memberInfo) public static string GetDocumentation(this ParameterInfo parameterInfo) { var memberDocumentation = parameterInfo.Member.GetDocumentation(); - if (!(memberDocumentation is null)) + if (memberDocumentation is not null) { var regexPattern = Regex.Escape(@"") + diff --git a/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnoucementPage.razor.cs b/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnoucementPage.razor.cs index 7403a006ea02..07c6c7ce1def 100644 --- a/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnoucementPage.razor.cs +++ b/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnoucementPage.razor.cs @@ -29,7 +29,7 @@ protected override async Task OnParametersSetAsync() protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender == true) + if (firstRender) { await NotificationService.MarkNotificationsAsRead(Id); } diff --git a/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnouncementOverviewPage.razor.cs b/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnouncementOverviewPage.razor.cs index 418954972023..184391314359 100644 --- a/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnouncementOverviewPage.razor.cs +++ b/src/MudBlazor.Docs/Pages/Mud/Announcements/AnnouncementOverviewPage.razor.cs @@ -23,7 +23,7 @@ protected override async Task OnInitializedAsync() protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender == true) + if (firstRender) { await NotificationService.MarkNotificationsAsRead(); } diff --git a/src/MudBlazor.Docs/Services/Notifications/InMemoryNotificationService.cs b/src/MudBlazor.Docs/Services/Notifications/InMemoryNotificationService.cs index b6cdb141f662..3b2ae8bbff37 100644 --- a/src/MudBlazor.Docs/Services/Notifications/InMemoryNotificationService.cs +++ b/src/MudBlazor.Docs/Services/Notifications/InMemoryNotificationService.cs @@ -69,7 +69,7 @@ public async Task MarkNotificationsAsRead(string id) } public Task GetMessageById(string id) => - Task.FromResult(_messages.FirstOrDefault((x => x.Id == id))); + Task.FromResult(_messages.FirstOrDefault(x => x.Id == id)); public async Task> GetNotifications() { diff --git a/src/MudBlazor.Docs/Shared/AppbarButtons.razor.cs b/src/MudBlazor.Docs/Shared/AppbarButtons.razor.cs index 50747287fef4..bf605f444c64 100644 --- a/src/MudBlazor.Docs/Shared/AppbarButtons.razor.cs +++ b/src/MudBlazor.Docs/Shared/AppbarButtons.razor.cs @@ -29,7 +29,7 @@ private async Task MarkNotificationAsRead() protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender == true) + if (firstRender) { _newNotificationsAvailable = await NotificationService.AreNewNotificationsAvailable(); _messages = await NotificationService.GetNotifications(); diff --git a/src/MudBlazor.SourceCodeGenerator/FastEnumDescriptionGenerator.cs b/src/MudBlazor.SourceCodeGenerator/FastEnumDescriptionGenerator.cs index 9a3518a06a6e..23923ff11f51 100644 --- a/src/MudBlazor.SourceCodeGenerator/FastEnumDescriptionGenerator.cs +++ b/src/MudBlazor.SourceCodeGenerator/FastEnumDescriptionGenerator.cs @@ -15,8 +15,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { var enums = context.SyntaxProvider.CreateSyntaxProvider( - transform: GetEnumData, - predicate: (syntaxNode, _) => syntaxNode is EnumDeclarationSyntax) + predicate: (syntaxNode, _) => syntaxNode is EnumDeclarationSyntax, + transform: GetEnumData) .Where(static enumData => enumData is not null); context.RegisterSourceOutput(enums, Build); } diff --git a/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableMultiSelectionServerDataTest.razor.cs b/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableMultiSelectionServerDataTest.razor.cs index 70b77b6e1b07..bb46d752a462 100644 --- a/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableMultiSelectionServerDataTest.razor.cs +++ b/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableMultiSelectionServerDataTest.razor.cs @@ -40,7 +40,7 @@ protected async Task> ServerData(TableState state, Canc TableData data = new(); data.TotalItems = _simulatedServerData.Count; // Serialize & deserialize to test a more real scenario where the references to the objects changes - string jsonData = JsonSerializer.Serialize(_simulatedServerData); + var jsonData = JsonSerializer.Serialize(_simulatedServerData); data.Items = JsonSerializer.Deserialize>(jsonData).Skip(state.PageSize * state.Page).Take(state.PageSize); return data; } diff --git a/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableRowsPerPageTwoWayBindingTest.razor.cs b/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableRowsPerPageTwoWayBindingTest.razor.cs index 6fff96f13ec1..2582241579f3 100644 --- a/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableRowsPerPageTwoWayBindingTest.razor.cs +++ b/src/MudBlazor.UnitTests.Viewer/TestComponents/Table/TableRowsPerPageTwoWayBindingTest.razor.cs @@ -69,7 +69,7 @@ public async Task LoadItemsAsync() var list = new List(); //delay to simulate web service call await Task.Delay(50).ConfigureAwait(false); - for (int i = 0; i < 20; i++) + for (var i = 0; i < 20; i++) { list.Add(new Item { Text = i.ToString() }); } diff --git a/src/MudBlazor.UnitTests/Components/AutocompleteTests.cs b/src/MudBlazor.UnitTests/Components/AutocompleteTests.cs index ec6d50dce45e..f3fd0e4f6f8d 100644 --- a/src/MudBlazor.UnitTests/Components/AutocompleteTests.cs +++ b/src/MudBlazor.UnitTests/Components/AutocompleteTests.cs @@ -475,11 +475,14 @@ public async Task Autocomplete_Should_SelectValue_On_Tab_With_SelectValueOnTab() } /// + /// /// When selecting a value by clicking on it in the list the input will blur. However, this /// must not cause the dropdown to close or else the click on the item will not be possible! - /// + /// + /// /// If this test fails it means the dropdown has closed before we can even click any value in the list. /// Such a regression happened and caused PR #1807 to be reverted + /// /// [Test] public async Task Autocomplete_Should_NotCloseDropdownOnInputBlur() diff --git a/src/MudBlazor.UnitTests/Components/BunitTest.cs b/src/MudBlazor.UnitTests/Components/BunitTest.cs index f03d1c72b445..cd7762d20981 100644 --- a/src/MudBlazor.UnitTests/Components/BunitTest.cs +++ b/src/MudBlazor.UnitTests/Components/BunitTest.cs @@ -33,20 +33,24 @@ public void TearDown() } /// + /// /// Note: This is a last resort measure to wrap around the logic of flaky tests which fail often (and /// especially on the integration server). - /// + /// + /// /// It reduces the chance of a perfectly working test to fail due to a race condition in bUnit by running it /// multiple times. If it succeeds at least once, the test passes. In the best-case scenario the test will run /// only once and pass. If it is particularly flaky it might run a few times until it passes. - /// + /// + /// /// If the test is really broken due to a bug /// it will fail for all runs. To get the original test output we run it one last time outside of the catch block /// so the test result gets reported. + /// /// protected async Task ImproveChanceOfSuccess(Func testAction) { - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { try { diff --git a/src/MudBlazor.UnitTests/Components/Charts/BarChartTests.cs b/src/MudBlazor.UnitTests/Components/Charts/BarChartTests.cs index e6db038bac87..08aafd063d48 100644 --- a/src/MudBlazor.UnitTests/Components/Charts/BarChartTests.cs +++ b/src/MudBlazor.UnitTests/Components/Charts/BarChartTests.cs @@ -51,7 +51,7 @@ public void BarChartEmptyData() [Test] public void BarChartExampleData() { - List chartSeries = new List() + var chartSeries = new List() { new () { Name = "United States", Data = new double[] { 40, 20, 25, 27, 46, 60, 48, 80, 15 } }, new () { Name = "Germany", Data = new double[] { 19, 24, 35, 13, 28, 15, -4, 16, 31 } }, @@ -112,7 +112,7 @@ public void BarChartExampleData() [Test] public void BarChartExampleSingleXAxis() { - List chartSeries = new List() + var chartSeries = new List() { new () { Name = "United States", Data = new double[] { 40, 20, 25, 27, 46, 60, 48, 80, 15 } }, new () { Name = "Germany", Data = new double[] { 19, 24, 35, 13, 28, 15, -4, 16, 31 } }, @@ -166,7 +166,7 @@ public void BarChartExampleSingleXAxis() [Test] public void BarChartColoring() { - List chartSeries = new List() + var chartSeries = new List() { new ChartSeries() { Name = "Deep Sea Blue", Data = new double[] { 40, 20, 25, 27, 46 } }, new ChartSeries() { Name = "Venetian Red", Data = new double[] { 19, 24, 35, 13, 28 } }, diff --git a/src/MudBlazor.UnitTests/Components/Charts/DonutChartTests.cs b/src/MudBlazor.UnitTests/Components/Charts/DonutChartTests.cs index e34aed88f915..0c8c3d83780c 100644 --- a/src/MudBlazor.UnitTests/Components/Charts/DonutChartTests.cs +++ b/src/MudBlazor.UnitTests/Components/Charts/DonutChartTests.cs @@ -116,15 +116,15 @@ public void DonutCirclePosition(double[] data) .Add(p => p.ChartOptions, new ChartOptions { ChartPalette = _baseChartPalette }) .Add(p => p.InputLabels, labels)); - var svgViewBox = comp.Find("svg").GetAttribute("viewBox")?.Split(" ")?.Select(s => Int32.Parse(s))?.ToArray(); + var svgViewBox = comp.Find("svg").GetAttribute("viewBox")?.Split(" ")?.Select(s => int.Parse(s))?.ToArray(); var circles = comp.FindAll("circle"); svgViewBox.Should().NotBeNullOrEmpty("must have a valid viewbox", svgViewBox); foreach (var c in circles) { - var cx = Int32.Parse(c.GetAttribute("cx") ?? "0"); - var cy = Int32.Parse(c.GetAttribute("cy") ?? "0"); + var cx = int.Parse(c.GetAttribute("cx") ?? "0"); + var cy = int.Parse(c.GetAttribute("cy") ?? "0"); cx.Should().Be(svgViewBox[2] / 2); diff --git a/src/MudBlazor.UnitTests/Components/Charts/LineChartTests.cs b/src/MudBlazor.UnitTests/Components/Charts/LineChartTests.cs index 3cbc36bae2ef..73fa9e494f10 100644 --- a/src/MudBlazor.UnitTests/Components/Charts/LineChartTests.cs +++ b/src/MudBlazor.UnitTests/Components/Charts/LineChartTests.cs @@ -57,7 +57,7 @@ public void LineChartEmptyData() [TestCaseSource("GetInterpolationOptions")] public void LineChartExampleData(InterpolationOption opt) { - List chartSeries = new List() + var chartSeries = new List() { new ChartSeries() { Name = "Series 1", Data = new double[] { 90, 79, -72, 69, 62, 62, -55, 65, 70 } }, new ChartSeries() { Name = "Series 2", Data = new double[] { 10, 41, 35, 51, 49, 62, -69, 91, -148 } }, @@ -152,7 +152,7 @@ public void LineChartExampleData(InterpolationOption opt) [TestCaseSource("GetInterpolationOptions")] public void LineChartExampleZeroValues(InterpolationOption opt) { - List chartSeries = new List() + var chartSeries = new List() { new ChartSeries() { Name = "Series 1", Data = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 } } }; @@ -201,7 +201,7 @@ public void LineChartExampleZeroValues(InterpolationOption opt) [Test] public void LineChartColoring() { - List chartSeries = new List() + var chartSeries = new List() { new ChartSeries() { Name = "Deep Sea Blue", Data = new double[] { 40, 20, 25, 27, 46 } }, new ChartSeries() { Name = "Venetian Red", Data = new double[] { 19, 24, 35, 13, 28 } }, diff --git a/src/MudBlazor.UnitTests/Components/Charts/StackedBarChartTests.cs b/src/MudBlazor.UnitTests/Components/Charts/StackedBarChartTests.cs index af88e22d30e6..4086c1ec750b 100644 --- a/src/MudBlazor.UnitTests/Components/Charts/StackedBarChartTests.cs +++ b/src/MudBlazor.UnitTests/Components/Charts/StackedBarChartTests.cs @@ -50,7 +50,7 @@ public void BarChartEmptyData() [Test] public void BarChartExampleData() { - List chartSeries = new List() + var chartSeries = new List() { new () { Name = "United States", Data = new double[] { 40, 20, 25, 27, 46, 60, 48, 80, 15 } }, new () { Name = "Germany", Data = new double[] { 19, 24, 35, 13, 28, 15, 13, 16, 31 } }, @@ -112,7 +112,7 @@ public void BarChartExampleData() [Test] public void StackedBarChartColoring() { - List chartSeries = new List() + var chartSeries = new List() { new ChartSeries() { Name = "Deep Sea Blue", Data = new double[] { 40, 20, 25, 27, 46 } }, new ChartSeries() { Name = "Venetian Red", Data = new double[] { 19, 24, 35, 13, 28 } }, diff --git a/src/MudBlazor.UnitTests/Components/ColorPickerTests.cs b/src/MudBlazor.UnitTests/Components/ColorPickerTests.cs index 92c0c207af12..32f7d396826e 100644 --- a/src/MudBlazor.UnitTests/Components/ColorPickerTests.cs +++ b/src/MudBlazor.UnitTests/Components/ColorPickerTests.cs @@ -76,7 +76,7 @@ public override void Setup() private void CheckColorRelatedValues(IRenderedComponent comp, double expectedX, double expectedY, MudColor expectedColor, ColorPickerMode mode, bool checkInstanceValue = true, bool isRtl = false) { - if (checkInstanceValue == true) + if (checkInstanceValue) { comp.WaitForAssertion(() => comp.Instance.ColorValue.Should().Be(expectedColor)); } @@ -97,7 +97,7 @@ private void CheckColorRelatedValues(IRenderedComponent c castedInputs[0].Value.Should().Be(expectedColor.H.ToString(CultureInfo.CurrentUICulture)); castedInputs[1].Value.Should().Be(expectedColor.S.ToString(CultureInfo.CurrentUICulture)); castedInputs[2].Value.Should().Be(expectedColor.L.ToString(CultureInfo.CurrentUICulture)); - castedInputs[3].Value.Should().Match(x => double.Parse(x, CultureInfo.CurrentUICulture) == Math.Round((expectedColor.A / 255.0), 2)); + castedInputs[3].Value.Should().Match(x => double.Parse(x, CultureInfo.CurrentUICulture) == Math.Round(expectedColor.A / 255.0, 2)); } } else if (mode == ColorPickerMode.HEX) @@ -447,7 +447,7 @@ public void Click_ColorPanel() overlay.Click(new MouseEventArgs { OffsetX = x, OffsetY = y }); MudColor color = "#232232ff"; - MudColor expectedColor = new MudColor(color.R, color.G, color.B, _defaultColor); + var expectedColor = new MudColor(color.R, color.G, color.B, _defaultColor); CheckColorRelatedValues(comp, x, y, expectedColor, ColorPickerMode.RGB); } @@ -1178,11 +1178,11 @@ public void StableHue_WhenColorSpectrumClicked() var overlay = comp.Find(CssSelector); - double expectedHue = _defaultColor.H; + var expectedHue = _defaultColor.H; - for (int x = 0; x < 312; x += 5) + for (var x = 0; x < 312; x += 5) { - for (int y = 0; y < 250; y += 5) + for (var y = 0; y < 250; y += 5) { overlay.Click(new MouseEventArgs { OffsetX = x, OffsetY = y }); @@ -1204,7 +1204,7 @@ public void Click_Selector_ColorPanel() overlay.Click(new MouseEventArgs { OffsetX = x, OffsetY = y }); MudColor color = "#232232ff"; - MudColor expectedColor = new MudColor(color.R, color.G, color.B, _defaultColor); + var expectedColor = new MudColor(color.R, color.G, color.B, _defaultColor); CheckColorRelatedValues(comp, x, y, expectedColor, ColorPickerMode.RGB); @@ -1217,7 +1217,7 @@ public void Click_Selector_ColorPanel() selector.Click(new MouseEventArgs { OffsetX = 5, OffsetY = 20 }); - MudColor secondExpectedColor = new MudColor(31, 30, 42, _defaultColor); + var secondExpectedColor = new MudColor(31, 30, 42, _defaultColor); CheckColorRelatedValues(comp, x - 8, y + 7, secondExpectedColor, ColorPickerMode.RGB); } diff --git a/src/MudBlazor.UnitTests/Components/DataGridTests.cs b/src/MudBlazor.UnitTests/Components/DataGridTests.cs index baa3b6a2d1ec..be3ffd88942a 100644 --- a/src/MudBlazor.UnitTests/Components/DataGridTests.cs +++ b/src/MudBlazor.UnitTests/Components/DataGridTests.cs @@ -469,7 +469,7 @@ public async Task DataGridEditableSelectionTest() dataGrid.FindAll("input.mud-checkbox-input")[^1].Change(false); dataGrid.Instance.SelectedItems.Count.Should().Be(0); //test that changing value in each row selects an item in grid - for (int i = 1; i < dataGrid.Instance.Items.Count(); i++) + for (var i = 1; i < dataGrid.Instance.Items.Count(); i++) { dataGrid.FindAll("input.mud-checkbox-input")[i].Change(true); dataGrid.Instance.SelectedItems.Count.Should().Be(i); diff --git a/src/MudBlazor.UnitTests/Components/DatePickerTests.cs b/src/MudBlazor.UnitTests/Components/DatePickerTests.cs index 296536f1873c..d9099bd23d6c 100644 --- a/src/MudBlazor.UnitTests/Components/DatePickerTests.cs +++ b/src/MudBlazor.UnitTests/Components/DatePickerTests.cs @@ -206,7 +206,7 @@ public async Task DataPicker_ShouldClearText_WhenDateSetNull() picker.Text.Should().Be(null); picker.Date.Should().Be(null); - string invalid = "INVALID_DATE"; + var invalid = "INVALID_DATE"; comp.SetParam(p => p.Text, "INVALID_DATE"); picker.Date.Should().Be(null); @@ -230,7 +230,7 @@ public async Task DataPicker_ShouldDeBounceSetDate_WhenDateSetToTheSameValueQuic picker.Text.Should().Be(null); picker.Date.Should().Be(null); - string invalid = "INVALID_DATE"; + var invalid = "INVALID_DATE"; comp.SetParam(p => p.Text, "INVALID_DATE"); picker.Date.Should().Be(null); @@ -614,7 +614,7 @@ public void IsDateDisabledFunc_DisablesCalendarDateButtons() comp.Instance.IsDateDisabledFunc.Should().Be(isDisabledFunc); comp.FindAll("button.mud-picker-calendar-day").Select(button => ((IHtmlButtonElement)button).IsDisabled) - .Should().OnlyContain(disabled => disabled == true); + .Should().OnlyContain(disabled => disabled); } [Test] @@ -630,7 +630,7 @@ public void IsDateDisabledFunc_DisablesCalendarMonthButtons() comp.Instance.IsDateDisabledFunc.Should().Be(isDisabledFunc); comp.FindAll("button.mud-picker-month").Select(button => ((IHtmlButtonElement)button).IsDisabled) - .Should().OnlyContain(disabled => disabled == true); + .Should().OnlyContain(disabled => disabled); // None should be selected comp.FindAll("button.mud-picker-month > .mud-typography").Select( @@ -1065,7 +1065,7 @@ public async Task DatePickerTest_Editable() { var comp = Context.RenderComponent(); - CultureInfo cultureInfo = new CultureInfo("en-US"); + var cultureInfo = new CultureInfo("en-US"); var datePicker = comp.FindComponent().Instance; datePicker.Editable = true; diff --git a/src/MudBlazor.UnitTests/Components/DateRangePickerTests.cs b/src/MudBlazor.UnitTests/Components/DateRangePickerTests.cs index 2228539c09d6..d90e8dec618b 100644 --- a/src/MudBlazor.UnitTests/Components/DateRangePickerTests.cs +++ b/src/MudBlazor.UnitTests/Components/DateRangePickerTests.cs @@ -458,7 +458,7 @@ public void IsDateDisabledFunc_DisablesCalendarDateButtons() comp.Instance.IsDateDisabledFunc.Should().Be(isDisabledFunc); comp.FindAll("button.mud-picker-calendar-day").Select(button => ((IHtmlButtonElement)button).IsDisabled) - .Should().OnlyContain(disabled => disabled == true); + .Should().OnlyContain(disabled => disabled); } [Test] diff --git a/src/MudBlazor.UnitTests/Components/DialogTests.cs b/src/MudBlazor.UnitTests/Components/DialogTests.cs index 83ba38406121..d7a0d1332d51 100644 --- a/src/MudBlazor.UnitTests/Components/DialogTests.cs +++ b/src/MudBlazor.UnitTests/Components/DialogTests.cs @@ -83,10 +83,11 @@ public async Task SimpleTest() } /// - /// Opening and closing an inline dialog. Click on open will open the inlined dialog. - /// + /// Opening and closing an inline dialog. Click on open will open the inlined dialog. + /// /// Note: this test uses two different components, one containing the dialog provider and /// one containing the open button and the inline dialog + /// /// [Test] public void InlineDialogTest() diff --git a/src/MudBlazor.UnitTests/Components/ListTests.cs b/src/MudBlazor.UnitTests/Components/ListTests.cs index a0af2dfc0dae..1da5ae7fb980 100644 --- a/src/MudBlazor.UnitTests/Components/ListTests.cs +++ b/src/MudBlazor.UnitTests/Components/ListTests.cs @@ -15,9 +15,8 @@ namespace MudBlazor.UnitTests.Components public class ListTests : BunitTest { /// - /// Clicking the drinks selects them. The child lists are updated accordingly, meaning, only ever 1 list item can have the active class. - /// - /// In this test no item is selected to begin with + /// Clicking the drinks selects them. The child lists are updated accordingly, meaning, only ever 1 list item can have the active class. + /// In this test no item is selected to begin with /// [Test] public async Task ListSelectionTest() @@ -46,9 +45,8 @@ public async Task ListSelectionTest() } /// - /// Clicking the drinks selects them. The child lists are updated accordingly, meaning, only ever 1 list item can have the active class. - /// - /// This test starts with a pre-selected item (by value) + /// Clicking the drinks selects them. The child lists are updated accordingly, meaning, only ever 1 list item can have the active class. + /// This test starts with a pre-selected item (by value) /// [Test] public async Task ListWithPreSelectedValueTest() diff --git a/src/MudBlazor.UnitTests/Components/PageContentNavigationTests.cs b/src/MudBlazor.UnitTests/Components/PageContentNavigationTests.cs index f4d78aabd6be..db81f3f31c86 100644 --- a/src/MudBlazor.UnitTests/Components/PageContentNavigationTests.cs +++ b/src/MudBlazor.UnitTests/Components/PageContentNavigationTests.cs @@ -44,7 +44,7 @@ public async Task AddSection(bool withUpdate) var section1 = new MudPageContentSection("my section", "my-id"); var section2 = new MudPageContentSection("my section 2", "my-id-2"); - if (withUpdate == true) + if (withUpdate) { await comp.InvokeAsync(() => comp.Instance.AddSection(section1, true)); await comp.InvokeAsync(() => comp.Instance.AddSection(section2, true)); @@ -56,7 +56,7 @@ public async Task AddSection(bool withUpdate) await comp.InvokeAsync(() => ((IMudStateHasChanged)comp.Instance).StateHasChanged()); } - comp.RenderCount.Should().Be(withUpdate == true ? 3 : 2); + comp.RenderCount.Should().Be(withUpdate ? 3 : 2); comp.Instance.ActiveSection.Should().BeNull(); comp.Instance.Sections.Should().BeEquivalentTo(new[] { section1, section2 }); diff --git a/src/MudBlazor.UnitTests/Components/PaginationTests.cs b/src/MudBlazor.UnitTests/Components/PaginationTests.cs index 6e6714e2089c..bb1015f2b26d 100644 --- a/src/MudBlazor.UnitTests/Components/PaginationTests.cs +++ b/src/MudBlazor.UnitTests/Components/PaginationTests.cs @@ -283,7 +283,7 @@ public async Task PaginationCountWithEllipsisTest(int selectedPage, int count, i //Expected values var items = comp.FindAll(".mud-pagination-item"); - items.Count.Should().Be(middleCount + 2 * boundaryCount + 2); + items.Count.Should().Be(middleCount + (2 * boundaryCount) + 2); for (var j = 0; j < items.Count; j++) { items[j].TextContent.Should().Be(expectedValues[j]); diff --git a/src/MudBlazor.UnitTests/Components/PopoverTests.cs b/src/MudBlazor.UnitTests/Components/PopoverTests.cs index 9fdb89bbdeac..a8d27ac4b867 100644 --- a/src/MudBlazor.UnitTests/Components/PopoverTests.cs +++ b/src/MudBlazor.UnitTests/Components/PopoverTests.cs @@ -293,7 +293,7 @@ public void MudPopoverHandler_UpdaterInvokationTest() RenderFragment newRenderFragement = (tree) => { }; - for (int i = 0; i < 4; i++) + for (var i = 0; i < 4; i++) { handler.UpdateFragment(newRenderFragement, comp.Instance, "my-extra-class", "my-extra-style:2px", i % 2 == 0); } @@ -330,7 +330,7 @@ public async Task MudPopoverHandler_UpdaterInvocationAsync() }); - for (int i = 0; i < 4; i++) + for (var i = 0; i < 4; i++) { await handler.UpdateFragmentAsync(newRenderFragment, comp.Instance, "my-extra-class", "my-extra-style:2px", i % 2 == 0); } @@ -616,10 +616,10 @@ public async Task MudPopoverService_CallInitializeOnlyOnce() It.IsAny(), It.Is(x => x.Length == 2 && (string)x[0] == "mudblazor-main-content" && (int)x[1] == 0))).ReturnsAsync(Mock.Of(), TimeSpan.FromMilliseconds(300)).Verifiable(); - Task[] tasks = new Task[5]; + var tasks = new Task[5]; var service = new MudPopoverService(mock.Object); - for (int i = 0; i < 5; i++) + for (var i = 0; i < 5; i++) { tasks[i] = Task.Run(async () => await service.InitializeIfNeeded()); } @@ -700,7 +700,7 @@ public void MudPopoverService_RegisterAndUseHandler() { var service = new MudPopoverService(Mock.Of(MockBehavior.Strict)); - int fragmentChangedCounter = 0; + var fragmentChangedCounter = 0; service.FragmentsChanged += (e, args) => { @@ -733,7 +733,7 @@ public async Task MudPopoverService_RegisterAndUseHandlerAsync() { var service = new MudPopoverService(Mock.Of(MockBehavior.Strict)); - int fragmentChangedCounter = 0; + var fragmentChangedCounter = 0; service.FragmentsChanged += (_, _) => { @@ -830,7 +830,7 @@ public async Task MudPopoverService_Unregister() await handler.Initialize(); - int fragmentChangedCounter = 0; + var fragmentChangedCounter = 0; service.FragmentsChanged += (_, _) => { @@ -1070,7 +1070,7 @@ public void MudPopoverProvider_RenderElementsBasedOnEnableState() var comp = Context.RenderComponent(p => p.Add(x => x.ProviderIsEnabled, true)); comp.Find("#my-content").TextContent.Should().Be("Popover content"); - for (int i = 0; i < 3; i++) + for (var i = 0; i < 3; i++) { comp.SetParametersAndRender(p => p.Add(x => x.ProviderIsEnabled, false)); Assert.Throws(() => comp.Find("#my-content")); @@ -1097,9 +1097,9 @@ public async Task MudPopoverProvider_ThrowOnDuplicate(bool ThrowOnDuplicateProvi }; Context.Services.Configure(x => x.ThrowOnDuplicateProvider = ThrowOnDuplicateProvider); - Context.JSInterop.Setup("mudpopoverHelper.countProviders").SetResult(ThrowOnDuplicateProvider == true ? 2 : 1); + Context.JSInterop.Setup("mudpopoverHelper.countProviders").SetResult(ThrowOnDuplicateProvider ? 2 : 1); - if (ThrowOnDuplicateProvider == true) + if (ThrowOnDuplicateProvider) { var ex = Assert.Throws(() => Context.RenderComponent()); ex.Message.Should().StartWith("Duplicate MudPopoverProvider detected"); diff --git a/src/MudBlazor.UnitTests/Components/ProgressLinearTests.cs b/src/MudBlazor.UnitTests/Components/ProgressLinearTests.cs index 441414d94436..943e98ffb3ea 100644 --- a/src/MudBlazor.UnitTests/Components/ProgressLinearTests.cs +++ b/src/MudBlazor.UnitTests/Components/ProgressLinearTests.cs @@ -110,7 +110,7 @@ public void DefaultStructure(bool isVertical) barElement.ClassList.Should().Contain("mud-progress-linear-bar"); barElement.GetAttribute("style").Should().Be( - isVertical == true ? + isVertical ? $"transform: translateY(90%);" : $"transform: translateX(-90%);"); } @@ -175,14 +175,14 @@ public void BufferStructure(bool isVertical) secondBarElement.ClassList.Should().Contain("mud-progress-linear-bar"); secondBarElement.GetAttribute("style").Should().Be( - isVertical == true ? + isVertical ? $"transform: translateY(90%);" : $"transform: translateX(-90%);"); var thirdBarElement = barContainer.Children[2]; thirdBarElement.ClassList.Should().Contain("mud-progress-linear-bar", "last"); thirdBarElement.GetAttribute("style").Should().Be( - isVertical == true ? + isVertical ? $"transform: translateY(60%);" : $"transform: translateX(-60%);"); } @@ -230,7 +230,7 @@ public void TestClassesForRounded(bool rounded) var container = comp.Find(".mud-progress-linear"); - if (rounded == true) + if (rounded) { container.ClassList.Should().Contain("mud-progress-linear-rounded"); } @@ -249,7 +249,7 @@ public void TestClassesForStriped(bool striped) var container = comp.Find(".mud-progress-linear"); - if (striped == true) + if (striped) { container.ClassList.Should().Contain("mud-progress-linear-striped"); } @@ -268,7 +268,7 @@ public void TestClassesForIntermediate(bool indeterminate) var container = comp.Find(".mud-progress-linear"); - if (indeterminate == true) + if (indeterminate) { container.ClassList.Should().Contain("mud-progress-indeterminate"); } @@ -294,7 +294,7 @@ public void TestClassesForBuffer(bool buffer, bool indeterminate) var container = comp.Find(".mud-progress-linear"); - if (buffer == true && indeterminate == false) + if (buffer && indeterminate == false) { container.ClassList.Should().Contain("mud-progress-linear-buffer"); } @@ -339,7 +339,7 @@ public void TestClassesForVertical(bool vertical) var container = comp.Find(".mud-progress-linear"); - if (vertical == true) + if (vertical) { container.ClassList.Should().Contain("vertical"); container.ClassList.Should().NotContain("horizontal"); diff --git a/src/MudBlazor.UnitTests/Components/SelectTests.cs b/src/MudBlazor.UnitTests/Components/SelectTests.cs index 8bc95de8fd51..1b07eabd9bc5 100644 --- a/src/MudBlazor.UnitTests/Components/SelectTests.cs +++ b/src/MudBlazor.UnitTests/Components/SelectTests.cs @@ -524,7 +524,7 @@ public void MultiSelect_SelectAll2() } // Check shadow items - var shadowItems = comp.FindComponents>().Where(x => x.Instance.HideContent == true).ToArray(); + var shadowItems = comp.FindComponents>().Where(x => x.Instance.HideContent).ToArray(); foreach (var item in shadowItems) { // shadow items don't render, their state is irrelevant, all they do is provide render fragments to the select diff --git a/src/MudBlazor.UnitTests/Components/SliderTests.cs b/src/MudBlazor.UnitTests/Components/SliderTests.cs index 96deac2daab5..fbc1aaef459a 100644 --- a/src/MudBlazor.UnitTests/Components/SliderTests.cs +++ b/src/MudBlazor.UnitTests/Components/SliderTests.cs @@ -276,7 +276,7 @@ public void TickMarksEnabled_ButLabels() tickMarks.ClassList.Should().Contain("mud-slider-tickmarks"); tickMarks.Children.Should().HaveCount(5); - Int32 itemCounter = 0; + var itemCounter = 0; foreach (var item in tickMarks.Children) { item.ClassList.Should().Contain(new[] { "d-flex", "flex-column", "relative" }); diff --git a/src/MudBlazor.UnitTests/Components/SwipeTests.cs b/src/MudBlazor.UnitTests/Components/SwipeTests.cs index 5b3709e2382d..6b1bd67a0685 100644 --- a/src/MudBlazor.UnitTests/Components/SwipeTests.cs +++ b/src/MudBlazor.UnitTests/Components/SwipeTests.cs @@ -76,7 +76,7 @@ public void SwipeTest_PreventDefault_SetTrue() var comp = Context.RenderComponent(ComponentParameter.CreateParameter("PreventDefault", true)); - comp.WaitForState(() => comp.Instance.PreventDefault == true); + comp.WaitForState(() => comp.Instance.PreventDefault); comp.Instance._listenerIds.Should().BeEquivalentTo(listenerIds); var invocation = handler.VerifyInvoke("mudElementRef.addDefaultPreventingHandlers"); diff --git a/src/MudBlazor.UnitTests/Components/TableTests.cs b/src/MudBlazor.UnitTests/Components/TableTests.cs index 2552cdb31cf2..9a07f91e7204 100644 --- a/src/MudBlazor.UnitTests/Components/TableTests.cs +++ b/src/MudBlazor.UnitTests/Components/TableTests.cs @@ -1434,7 +1434,7 @@ public async Task TableInlineEdit_TableRowValidator() validator.ControlCount.Should().Be(1); for (var i = 0; i < 10; ++i) { - trs[i % 3 + 1].Click(); + trs[(i % 3) + 1].Click(); } validator.ControlCount.Should().Be(1); } @@ -1566,7 +1566,7 @@ public async Task TableInlineEditSortTest() trs[2].Click(); // Change row two data - var input = comp.Find(("#Id1")); + var input = comp.Find("#Id1"); input.Change("D"); // Check row two is still in position 2 of the data rows @@ -2208,8 +2208,8 @@ public void TablePagerControlButtonAriaLabelTest(Page controlButton, string expe [Test] public async Task RowsPerPageParameterTwoWayBinding() { - int rowsPerPage = 5; - int newRowsPerPage = 25; + var rowsPerPage = 5; + var newRowsPerPage = 25; var comp = Context.RenderComponent(parameters => parameters .Add(p => p.RowsPerPage, rowsPerPage) .Add(p => p.RowsPerPageChanged, (s) => @@ -2302,7 +2302,7 @@ public async Task TableRecordEditingMultiSelectTest() trs[2].Click(); // Change row two data - var input = comp.Find(("#Id2")); + var input = comp.Find("#Id2"); input.Change("Change"); table.SelectedItems.Count.Should().Be(3); diff --git a/src/MudBlazor.UnitTests/Components/TextFieldTests.cs b/src/MudBlazor.UnitTests/Components/TextFieldTests.cs index d917eba2224f..4ff9015cdb47 100644 --- a/src/MudBlazor.UnitTests/Components/TextFieldTests.cs +++ b/src/MudBlazor.UnitTests/Components/TextFieldTests.cs @@ -364,9 +364,8 @@ public async Task MultilineTextField_Should_UpdateTextOnInput() } /// - /// This is based on a bug reported by a user - /// - /// After editing the second (multi-line) tf it would not accept any updates from the first tf. + /// This is based on a bug reported by a user + /// After editing the second (multi-line) tf it would not accept any updates from the first tf. /// [Test] public async Task MultiLineTextField_ShouldBe_TwoWayBindable() diff --git a/src/MudBlazor.UnitTests/Components/ThemeProviderTests.cs b/src/MudBlazor.UnitTests/Components/ThemeProviderTests.cs index 1b25cd29776a..80e51f82815a 100644 --- a/src/MudBlazor.UnitTests/Components/ThemeProviderTests.cs +++ b/src/MudBlazor.UnitTests/Components/ThemeProviderTests.cs @@ -363,7 +363,7 @@ public void PseudoCssScope_Test(string scope) [Test] public void PseudoCssRootColor_Test() { - string scope = ":root"; + var scope = ":root"; var isDarkMode = true; var mudTheme = new MudTheme { diff --git a/src/MudBlazor.UnitTests/Components/TimePickerTests.cs b/src/MudBlazor.UnitTests/Components/TimePickerTests.cs index f69e5117f0c1..13290ad9afe8 100644 --- a/src/MudBlazor.UnitTests/Components/TimePickerTests.cs +++ b/src/MudBlazor.UnitTests/Components/TimePickerTests.cs @@ -346,7 +346,7 @@ public void TimeEditModeNormal_CheckMinutesHidden() [Test] public void TimeEditModeHours_CheckSelection() { - var comp = Context.RenderComponent((Parameter("TimeEditMode", TimeEditMode.OnlyHours))); + var comp = Context.RenderComponent(Parameter("TimeEditMode", TimeEditMode.OnlyHours)); var underlyingPicker = comp.FindComponent().Instance; // click to to open picker diff --git a/src/MudBlazor.UnitTests/Components/TimelineTests.cs b/src/MudBlazor.UnitTests/Components/TimelineTests.cs index c53d6d0fe948..e9adae5bf871 100644 --- a/src/MudBlazor.UnitTests/Components/TimelineTests.cs +++ b/src/MudBlazor.UnitTests/Components/TimelineTests.cs @@ -128,7 +128,7 @@ public void TimelineTest_SelectItem() itemsDiv.Should().HaveCount(5); - for (int i = 0; i < 5; i++) + for (var i = 0; i < 5; i++) { itemsDiv[i].Click(); diff --git a/src/MudBlazor.UnitTests/Components/TreeViewTest.cs b/src/MudBlazor.UnitTests/Components/TreeViewTest.cs index 4ae890c8f670..73b68b30e908 100644 --- a/src/MudBlazor.UnitTests/Components/TreeViewTest.cs +++ b/src/MudBlazor.UnitTests/Components/TreeViewTest.cs @@ -179,7 +179,7 @@ public async Task TreeView_OtherTest() public async Task TreeViewItem_DoubleClick_CheckExpanded() { var comp = Context.RenderComponent(); - bool itemIsExpanded = false; + var itemIsExpanded = false; var item = comp.FindComponent>(); await item.InvokeAsync(() => diff --git a/src/MudBlazor.UnitTests/Mocks/MockDocsMessageHandler.cs b/src/MudBlazor.UnitTests/Mocks/MockDocsMessageHandler.cs index 6b9cc02e5272..0e735063e326 100644 --- a/src/MudBlazor.UnitTests/Mocks/MockDocsMessageHandler.cs +++ b/src/MudBlazor.UnitTests/Mocks/MockDocsMessageHandler.cs @@ -5,7 +5,7 @@ namespace MudBlazor.UnitTests.Mocks { public class MockDocsMessageHandler : MockHttpMessageHandler { - public MockDocsMessageHandler() : base() + public MockDocsMessageHandler() { // Periodic table api this.When("https://localhost/webapi/periodictable") diff --git a/src/MudBlazor.UnitTests/Mocks/MockEventListener.cs b/src/MudBlazor.UnitTests/Mocks/MockEventListener.cs index 2945a7b2aae0..c830a9ec47e6 100644 --- a/src/MudBlazor.UnitTests/Mocks/MockEventListener.cs +++ b/src/MudBlazor.UnitTests/Mocks/MockEventListener.cs @@ -58,7 +58,7 @@ public Task SubscribeGlobal(string eventName, int throotleInterval, Fun public Task Unsubscribe(Guid key) { var result = Callbacks.ContainsKey(key); - if (result == true) + if (result) { Callbacks.Remove(key); ElementIdMapper.Remove(key); diff --git a/src/MudBlazor.UnitTests/Mocks/MockNavigationManager.cs b/src/MudBlazor.UnitTests/Mocks/MockNavigationManager.cs index fab59c943725..834179df9888 100644 --- a/src/MudBlazor.UnitTests/Mocks/MockNavigationManager.cs +++ b/src/MudBlazor.UnitTests/Mocks/MockNavigationManager.cs @@ -5,14 +5,14 @@ namespace MudBlazor.UnitTests.Mocks public class MockNavigationManager : NavigationManager { - public MockNavigationManager() : base() => - this.Initialize("http://localhost:2112/", "http://localhost:2112/test"); + public MockNavigationManager() => + Initialize("http://localhost:2112/", "http://localhost:2112/test"); - public MockNavigationManager(string baseUri, string uri) : base() => - this.Initialize(baseUri, uri); + public MockNavigationManager(string baseUri, string uri) => + Initialize(baseUri, uri); protected override void NavigateToCore(string uri, bool forceLoad) => - this.WasNavigateInvoked = true; + WasNavigateInvoked = true; public bool WasNavigateInvoked { get; private set; } } diff --git a/src/MudBlazor.UnitTests/Mocks/MockResizeObserver.cs b/src/MudBlazor.UnitTests/Mocks/MockResizeObserver.cs index 459d7e6ce11d..5795d246d91a 100644 --- a/src/MudBlazor.UnitTests/Mocks/MockResizeObserver.cs +++ b/src/MudBlazor.UnitTests/Mocks/MockResizeObserver.cs @@ -27,7 +27,7 @@ public MockResizeObserverFactory(MockResizeObserver observer) public IResizeObserver Create() => Create(new ResizeObserverOptions()); } - public class MockResizeObserver : IResizeObserver, IDisposable + public class MockResizeObserver : IResizeObserver { private Dictionary _cachedValues = new(); @@ -76,7 +76,7 @@ public void UpdatePanelSize(int index, double newSize) public async Task Observe(ElementReference element) => (await Observe(new[] { element })).FirstOrDefault(); - private Boolean _firstBatchProcessed = false; + private bool _firstBatchProcessed = false; public Task> Observe(IEnumerable elements) { @@ -90,7 +90,7 @@ public Task> Observe(IEnumerable components = typeof(MudElement).Assembly.GetTypes() + var components = typeof(MudElement).Assembly.GetTypes() .Where(type => type.IsSubclassOf(typeof(MudComponentBase))) .Except(exceptions); - foreach (Type component in components) + foreach (var component in components) { - foreach (PropertyInfo property in component.GetProperties()) + foreach (var property in component.GetProperties()) { if (GetBaseDefinitionClass(property) == component && // property isn't inherited !property.PropertyType.Name.Contains("EventCallback") && // property isn't an event callback diff --git a/src/MudBlazor.UnitTests/Services/EventListenerTests.cs b/src/MudBlazor.UnitTests/Services/EventListenerTests.cs index 56ce4d4b7623..12e88c8bc02b 100644 --- a/src/MudBlazor.UnitTests/Services/EventListenerTests.cs +++ b/src/MudBlazor.UnitTests/Services/EventListenerTests.cs @@ -39,7 +39,7 @@ public void SetUp() #endif } - private bool ContainsEqual(IEnumerable firstColl, IEnumerable secondColl) + private bool ContainsEqual(IEnumerable firstColl, IEnumerable secondColl) { try { @@ -60,7 +60,7 @@ public async Task Subscribe() var throttleInterval = 20; var projectionName = "mynamespace.myfunction"; - Func callback = (x) => Task.Delay(10); + Func callback = (x) => Task.Delay(10); _runtimeMock.Setup(x => x.InvokeAsync("mudThrottledEventManager.subscribe", It.Is(z => (string)z[0] == eventName && @@ -68,7 +68,7 @@ public async Task Subscribe() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); @@ -95,7 +95,7 @@ public async Task Subscribe_AndCallback() var offsetX = 200.24; var offsetY = 12425.2; - Func callback = (x) => + Func callback = (x) => { try { @@ -120,7 +120,7 @@ public async Task Subscribe_AndCallback() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); @@ -152,7 +152,7 @@ public async Task Subscribe_AndUnsubscribe() var throttleInterval = 20; string projectionName = null; - Func callback = (x) => Task.Delay(10); + Func callback = (x) => Task.Delay(10); _runtimeMock.Setup(x => x.InvokeAsync("mudThrottledEventManager.subscribe", It.Is(z => z.Length == 7 && @@ -161,7 +161,7 @@ public async Task Subscribe_AndUnsubscribe() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); @@ -187,7 +187,7 @@ public async Task Subscribe_AndUnsubscribe_WithError() var throttleInterval = 20; var projectionName = "mynamspace.something.somethingelse"; - Func callback = (x) => Task.Delay(10); + Func callback = (x) => Task.Delay(10); _runtimeMock.Setup(x => x.InvokeAsync("mudThrottledEventManager.subscribe", It.Is(z => z.Length == 7 && @@ -196,7 +196,7 @@ public async Task Subscribe_AndUnsubscribe_WithError() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); @@ -222,7 +222,7 @@ public async Task DisposeAsync() var throttleInterval = 20; var projectionName = "mynamspace.something.somethingelse"; - Func callback = (x) => Task.Delay(10); + Func callback = (x) => Task.Delay(10); for (var i = 0; i < 10; i++) { @@ -235,7 +235,7 @@ public async Task DisposeAsync() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); @@ -277,7 +277,7 @@ public async Task Dispose() var throttleInterval = 20; var projectionName = "mynamspace.something.somethingelse"; - Func callback = (x) => Task.Delay(10); + Func callback = (x) => Task.Delay(10); for (var i = 0; i < 10; i++) { @@ -290,7 +290,7 @@ public async Task Dispose() (string)z[2] == projectionName && (int)z[3] == throttleInterval && (Guid)z[4] != Guid.Empty && - ContainsEqual((IEnumerable)z[5], _expectedProperties) == true && + ContainsEqual((IEnumerable)z[5], _expectedProperties) && z[6] is DotNetObjectReference ))).ReturnsAsync(Mock.Of); diff --git a/src/MudBlazor.UnitTests/Services/ResizeObserverTests.cs b/src/MudBlazor.UnitTests/Services/ResizeObserverTests.cs index 9ebe53ba4c4a..ebba57f39fb8 100644 --- a/src/MudBlazor.UnitTests/Services/ResizeObserverTests.cs +++ b/src/MudBlazor.UnitTests/Services/ResizeObserverTests.cs @@ -69,10 +69,10 @@ public async Task ObserveAndCache() "mudResizeObserver.connect", It.Is(z => (Guid)z[0] != default && - (z[1] is DotNetObjectReference) == true && - (z[2] is IEnumerable) == true && - (z[3] is IEnumerable) == true && - (z[4] is ResizeObserverOptions) == true && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 + (z[1] is DotNetObjectReference) && + (z[2] is IEnumerable) && + (z[3] is IEnumerable) && + (z[4] is ResizeObserverOptions) && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 ) )).ReturnsAsync(resolvedElements.Values).Verifiable(); @@ -162,12 +162,12 @@ public async Task Unobserve() "mudResizeObserver.connect", It.Is(z => (Guid)z[0] != default && - (z[1] is DotNetObjectReference) == true && - (z[2] is IEnumerable) == true && - (z[3] is IEnumerable) == true && - (z[4] is ResizeObserverOptions) == true && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 + (z[1] is DotNetObjectReference) && + (z[2] is IEnumerable) && + (z[3] is IEnumerable) && + (z[4] is ResizeObserverOptions) && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 ) - )).ReturnsAsync(resolvedElements.Values).Callback((x, y) => { observerId = (Guid)y[0]; ids = new List((IEnumerable)y[3]); }).Verifiable(); + )).ReturnsAsync(resolvedElements.Values).Callback((x, y) => { observerId = (Guid)y[0]; ids = new List((IEnumerable)y[3]); }).Verifiable(); foreach (var item in resolvedElements) @@ -176,9 +176,9 @@ public async Task Unobserve() "mudResizeObserver.disconnect", It.Is(z => (Guid)z[0] == observerId && - ids.Contains((Guid)z[1]) == true + ids.Contains((Guid)z[1]) ) - )).ReturnsAsync(Mock.Of).Callback((x, y) => { ids.Remove((Guid)y[1]); }).Verifiable(); + )).ReturnsAsync(Mock.Of).Callback((x, y) => { ids.Remove((Guid)y[1]); }).Verifiable(); } await _service.Observe(resolvedElements.Keys); @@ -220,12 +220,12 @@ public async Task OnSizeChanged() "mudResizeObserver.connect", It.Is(z => (Guid)z[0] != default && - (z[1] is DotNetObjectReference) == true && - (z[2] is IEnumerable) == true && - (z[3] is IEnumerable) == true && - (z[4] is ResizeObserverOptions) == true && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 + (z[1] is DotNetObjectReference) && + (z[2] is IEnumerable) && + (z[3] is IEnumerable) && + (z[4] is ResizeObserverOptions) && ((ResizeObserverOptions)z[4]).EnableLogging == false && ((ResizeObserverOptions)z[4]).ReportRate == 200 ) - )).ReturnsAsync(resolvedElements.Values).Callback((x, y) => { ids = new List((IEnumerable)y[3]); }).Verifiable(); + )).ReturnsAsync(resolvedElements.Values).Callback((x, y) => { ids = new List((IEnumerable)y[3]); }).Verifiable(); await _service.Observe(resolvedElements.Keys); diff --git a/src/MudBlazor.UnitTests/Utilities/AsyncKeyedLock/AsyncKeyedLockTests.cs b/src/MudBlazor.UnitTests/Utilities/AsyncKeyedLock/AsyncKeyedLockTests.cs index f40a05262904..597ee22cfedd 100644 --- a/src/MudBlazor.UnitTests/Utilities/AsyncKeyedLock/AsyncKeyedLockTests.cs +++ b/src/MudBlazor.UnitTests/Utilities/AsyncKeyedLock/AsyncKeyedLockTests.cs @@ -384,7 +384,7 @@ public async Task TestTimeoutWithTimeSpan() public void TestTimeoutWithInfiniteTimeoutAndCancellationToken() { var asyncKeyedLocker = new AsyncKeyedLocker(); - using (asyncKeyedLocker.Lock("test", Timeout.Infinite, new CancellationToken(false), out bool entered)) + using (asyncKeyedLocker.Lock("test", Timeout.Infinite, new CancellationToken(false), out var entered)) { entered.Should().BeTrue(); asyncKeyedLocker.IsInUse("test").Should().BeTrue(); diff --git a/src/MudBlazor.UnitTests/Utilities/Mask/MultiMaskTests.cs b/src/MudBlazor.UnitTests/Utilities/Mask/MultiMaskTests.cs index 232af97c094a..b250fb075caf 100644 --- a/src/MudBlazor.UnitTests/Utilities/Mask/MultiMaskTests.cs +++ b/src/MudBlazor.UnitTests/Utilities/Mask/MultiMaskTests.cs @@ -28,7 +28,7 @@ public void MultiMask_Test() new MaskOption("Discover", "0000 0000 0000 0000", @"^(6011|65|64[4-9])") ); MaskOption? option = null; - int eventCount = 0; + var eventCount = 0; mask.OptionDetected = (o, text) => { eventCount++; diff --git a/src/MudBlazor.UnitTests/Utilities/NaturalComparerTest.cs b/src/MudBlazor.UnitTests/Utilities/NaturalComparerTest.cs index 73869d4c7b36..bb46796ccbd4 100644 --- a/src/MudBlazor.UnitTests/Utilities/NaturalComparerTest.cs +++ b/src/MudBlazor.UnitTests/Utilities/NaturalComparerTest.cs @@ -19,9 +19,9 @@ public class NaturalComparerTest { int o; while ((o = s.IndexOf('\\')) != -1) { - int p = o + 1; - int z = 1; while (s[p] == '0') { z++; p++; } - int c = Int32.Parse(s.Substring(p, z)); + var p = o + 1; + var z = 1; while (s[p] == '0') { z++; p++; } + var c = int.Parse(s.Substring(p, z)); s = s.Substring(0, o) + new string(s[o - 1], c) + s.Substring(p + z); } return s; @@ -339,11 +339,11 @@ public class NaturalComparerTest [Test] public void SortFiles() { - string[] fileNames = Encoding.UTF8.GetString(Convert.FromBase64String(s_encodedFileNames)) + var fileNames = Encoding.UTF8.GetString(Convert.FromBase64String(s_encodedFileNames)) .Replace("*", ".txt?").Split(new[] { "?" }, StringSplitOptions.RemoveEmptyEntries) .Select(n => _expand(n)).ToArray(); - string[] orderedFiles = fileNames.OrderBy(x => x, new NaturalComparer()).ToArray(); + var orderedFiles = fileNames.OrderBy(x => x, new NaturalComparer()).ToArray(); orderedFiles.Should().NotBeEmpty(); orderedFiles.Should().ContainInOrder(s_orderedFileNames); diff --git a/src/MudBlazor.UnitTests/Utilities/SortingAssistentTests.cs b/src/MudBlazor.UnitTests/Utilities/SortingAssistentTests.cs index b595cdc89b0c..caba3a562df6 100644 --- a/src/MudBlazor.UnitTests/Utilities/SortingAssistentTests.cs +++ b/src/MudBlazor.UnitTests/Utilities/SortingAssistentTests.cs @@ -21,7 +21,7 @@ public class ItemsWithOrder public string Name { get; } public int Prio { get; set; } - public ItemsWithOrder(String name, int priority) + public ItemsWithOrder(string name, int priority) { Name = name; Prio = priority; diff --git a/src/MudBlazor/Base/MudBaseInput.cs b/src/MudBlazor/Base/MudBaseInput.cs index 80a4338709e9..926ff48b7fd5 100644 --- a/src/MudBlazor/Base/MudBaseInput.cs +++ b/src/MudBlazor/Base/MudBaseInput.cs @@ -352,7 +352,7 @@ public T Value protected virtual async Task SetValueAsync(T value, bool updateText = true, bool force = false) { - if (!EqualityComparer.Default.Equals(Value, value) || force == true) + if (!EqualityComparer.Default.Equals(Value, value) || force) { _isDirty = true; _validated = false; @@ -501,8 +501,8 @@ protected override void OnParametersSet() protected override async Task ResetValueAsync() { await SetTextAsync(null, updateValue: true); - this._isDirty = false; - this._validated = false; + _isDirty = false; + _validated = false; await base.ResetValueAsync(); } } diff --git a/src/MudBlazor/Base/MudBooleanInput.cs b/src/MudBlazor/Base/MudBooleanInput.cs index d6ea703b20c7..48a362fadb80 100644 --- a/src/MudBlazor/Base/MudBooleanInput.cs +++ b/src/MudBlazor/Base/MudBooleanInput.cs @@ -125,7 +125,7 @@ protected override bool SetConverter(Converter value) /// protected override bool HasValue(T? value) { - return (BoolValue == true); + return BoolValue == true; } } } diff --git a/src/MudBlazor/Base/MudComponentBase.cs b/src/MudBlazor/Base/MudComponentBase.cs index 7c734ad31d88..8da8e723fa04 100644 --- a/src/MudBlazor/Base/MudComponentBase.cs +++ b/src/MudBlazor/Base/MudComponentBase.cs @@ -56,7 +56,7 @@ public abstract partial class MudComponentBase : ComponentBase, IMudStateHasChan /// /// If the UserAttributes contain an ID make it accessible for WCAG labelling of input fields /// - public string FieldId => (UserAttributes?.ContainsKey("id") == true ? UserAttributes["id"]?.ToString() ?? $"mudinput-{Guid.NewGuid()}" : $"mudinput-{Guid.NewGuid()}"); + public string FieldId => UserAttributes?.ContainsKey("id") == true ? UserAttributes["id"]?.ToString() ?? $"mudinput-{Guid.NewGuid()}" : $"mudinput-{Guid.NewGuid()}"; /// protected override void OnAfterRender(bool firstRender) diff --git a/src/MudBlazor/Base/MudFormComponent.cs b/src/MudBlazor/Base/MudFormComponent.cs index 89e80654035d..14c266212b7d 100644 --- a/src/MudBlazor/Base/MudFormComponent.cs +++ b/src/MudBlazor/Base/MudFormComponent.cs @@ -160,11 +160,14 @@ protected virtual void OnConversionErrorOccurred(string error) } /// + /// /// This manages the state of having been "touched" by the user. A form control always starts out untouched /// but becomes touched when the user performed input or the blur event was raised. - /// + /// + /// /// The touched state is only relevant for inputs that have no value (i.e. empty text fields). Being untouched will /// suppress RequiredError + /// /// public bool Touched { get; protected set; } diff --git a/src/MudBlazor/Components/AppBar/MudAppBar.razor.cs b/src/MudBlazor/Components/AppBar/MudAppBar.razor.cs index d3c656750b03..22b87edb3602 100644 --- a/src/MudBlazor/Components/AppBar/MudAppBar.razor.cs +++ b/src/MudBlazor/Components/AppBar/MudAppBar.razor.cs @@ -43,7 +43,7 @@ public partial class MudAppBar : MudComponentBase public bool Dense { get; set; } /// - /// If true, the left and right padding is removed from from the appbar. + /// If true, the left and right padding is removed from the appbar. /// [Parameter] [Category(CategoryTypes.AppBar.Appearance)] diff --git a/src/MudBlazor/Components/Autocomplete/MudAutocomplete.razor.cs b/src/MudBlazor/Components/Autocomplete/MudAutocomplete.razor.cs index 23c25cb5c01e..552a49090f1f 100644 --- a/src/MudBlazor/Components/Autocomplete/MudAutocomplete.razor.cs +++ b/src/MudBlazor/Components/Autocomplete/MudAutocomplete.razor.cs @@ -11,7 +11,7 @@ namespace MudBlazor { - public partial class MudAutocomplete : MudBaseInput, IDisposable + public partial class MudAutocomplete : MudBaseInput { /// /// We need a random id for the year items in the year list so we can scroll to the item safely in every DatePicker. @@ -644,7 +644,7 @@ internal virtual async Task OnInputKeyUp(KeyboardEventArgs args) } break; case "ArrowUp": - if (args.AltKey == true) + if (args.AltKey) { await ChangeMenu(open: false); } @@ -671,7 +671,7 @@ internal virtual async Task OnInputKeyUp(KeyboardEventArgs args) await ToggleMenu(); break; case "Backspace": - if (args.CtrlKey == true && args.ShiftKey == true) + if (args.CtrlKey && args.ShiftKey) { await ResetAsync(); } @@ -685,7 +685,7 @@ private ValueTask SelectNextItem(int increment) if (increment == 0 || _items == null || _items.Length == 0 || !_enabledItemIndices.Any()) return ValueTask.CompletedTask; // if we are at the end, or the beginning we just do an rollover - _selectedListItemIndex = Math.Clamp(value: (10 * _items.Length + _selectedListItemIndex + increment) % _items.Length, min: 0, max: _items.Length - 1); + _selectedListItemIndex = Math.Clamp(value: ((10 * _items.Length) + _selectedListItemIndex + increment) % _items.Length, min: 0, max: _items.Length - 1); return ScrollToListItem(_selectedListItemIndex); } diff --git a/src/MudBlazor/Components/Chart/Charts/Bar.razor.cs b/src/MudBlazor/Components/Chart/Charts/Bar.razor.cs index 46cd456fa8c2..0cf9c28235c4 100644 --- a/src/MudBlazor/Components/Chart/Charts/Bar.razor.cs +++ b/src/MudBlazor/Components/Chart/Charts/Bar.razor.cs @@ -35,7 +35,7 @@ protected override void OnParametersSet() if (MudChartParent != null) _series = MudChartParent.ChartSeries; - ComputeUnitsAndNumberOfLines(out double gridXUnits, out double gridYUnits, out int numHorizontalLines, out int lowestHorizontalLine, out int numVerticalLines); + ComputeUnitsAndNumberOfLines(out var gridXUnits, out var gridYUnits, out var numHorizontalLines, out var lowestHorizontalLine, out var numVerticalLines); var horizontalSpace = (BoundWidth - HorizontalStartSpace - HorizontalEndSpace) / Math.Max(1, numVerticalLines - 1); var verticalSpace = (BoundHeight - VerticalStartSpace - VerticalEndSpace) / Math.Max(1, numHorizontalLines - 1); @@ -62,7 +62,7 @@ private void ComputeUnitsAndNumberOfLines(out double gridXUnits, out double grid numHorizontalLines = highestHorizontalLine - lowestHorizontalLine + 1; // this is a safeguard against millions of gridlines which might arise with very high values - int maxYTicks = MudChartParent?.ChartOptions.MaxNumYAxisTicks ?? 100; + var maxYTicks = MudChartParent?.ChartOptions.MaxNumYAxisTicks ?? 100; while (numHorizontalLines > maxYTicks) { gridYUnits *= 2; @@ -88,11 +88,11 @@ private void GenerateHorizontalGridLines(int numHorizontalLines, int lowestHoriz for (var i = 0; i < numHorizontalLines; i++) { - var y = VerticalStartSpace + i * verticalSpace; + var y = VerticalStartSpace + (i * verticalSpace); var line = new SvgPath() { Index = i, - Data = $"M {ToS(HorizontalStartSpace)} {ToS((BoundHeight - y))} L {ToS((BoundWidth - HorizontalEndSpace))} {ToS((BoundHeight - y))}" + Data = $"M {ToS(HorizontalStartSpace)} {ToS(BoundHeight - y)} L {ToS(BoundWidth - HorizontalEndSpace)} {ToS(BoundHeight - y)}" }; _horizontalLines.Add(line); @@ -114,11 +114,11 @@ private void GenerateVerticalGridLines(int numVerticalLines, double gridXUnits, for (var i = 0; i < numVerticalLines; i++) { - var x = HorizontalStartSpace + i * horizontalSpace; + var x = HorizontalStartSpace + (i * horizontalSpace); var line = new SvgPath() { Index = i, - Data = $"M {ToS(x)} {ToS((BoundHeight - VerticalStartSpace))} L {ToS(x)} {ToS(VerticalEndSpace)}" + Data = $"M {ToS(x)} {ToS(BoundHeight - VerticalStartSpace)} L {ToS(x)} {ToS(VerticalEndSpace)}" }; _verticalLines.Add(line); @@ -144,9 +144,9 @@ private void GenerateBars(int lowestHorizontalLine, double gridYUnits, double ho for (var j = 0; j < data.Length; j++) { - var gridValueX = HorizontalStartSpace + i * 10 + j * horizontalSpace; - var gridValueY = BoundHeight - VerticalStartSpace + lowestHorizontalLine * verticalSpace; - var dataValue = (data[j] / gridYUnits - lowestHorizontalLine) * verticalSpace; + var gridValueX = HorizontalStartSpace + (i * 10) + (j * horizontalSpace); + var gridValueY = BoundHeight - VerticalStartSpace + (lowestHorizontalLine * verticalSpace); + var dataValue = ((data[j] / gridYUnits) - lowestHorizontalLine) * verticalSpace; var gridValue = BoundHeight - VerticalStartSpace - dataValue; var bar = new SvgPath() diff --git a/src/MudBlazor/Components/Chart/Charts/Donut.razor.cs b/src/MudBlazor/Components/Chart/Charts/Donut.razor.cs index 2fe67da139c7..3efedd8eff11 100644 --- a/src/MudBlazor/Components/Chart/Charts/Donut.razor.cs +++ b/src/MudBlazor/Components/Chart/Charts/Donut.razor.cs @@ -27,7 +27,7 @@ protected override void OnParametersSet() { var percent = data * 100; var reversePercent = 100 - percent; - double offset = 100 - totalPercent + counterClockwiseOffset; + var offset = 100 - totalPercent + counterClockwiseOffset; totalPercent += percent; var circle = new SvgCircle() diff --git a/src/MudBlazor/Components/Chart/Charts/Line.razor.cs b/src/MudBlazor/Components/Chart/Charts/Line.razor.cs index 94220da886b6..77557cfff7c4 100644 --- a/src/MudBlazor/Components/Chart/Charts/Line.razor.cs +++ b/src/MudBlazor/Components/Chart/Charts/Line.razor.cs @@ -38,7 +38,7 @@ protected override void OnParametersSet() if (MudChartParent != null) _series = MudChartParent.ChartSeries; - ComputeUnitsAndNumberOfLines(out double gridXUnits, out double gridYUnits, out int numHorizontalLines, out int lowestHorizontalLine, out int numVerticalLines); + ComputeUnitsAndNumberOfLines(out var gridXUnits, out var gridYUnits, out var numHorizontalLines, out var lowestHorizontalLine, out var numVerticalLines); var horizontalSpace = (BoundWidth - HorizontalStartSpace - HorizontalEndSpace) / Math.Max(1, numVerticalLines - 1); var verticalSpace = (BoundHeight - VerticalStartSpace - VerticalEndSpace) / Math.Max(1, numHorizontalLines - 1); @@ -65,7 +65,7 @@ private void ComputeUnitsAndNumberOfLines(out double gridXUnits, out double grid numHorizontalLines = highestHorizontalLine - lowestHorizontalLine + 1; // this is a safeguard against millions of gridlines which might arise with very high values - int maxYTicks = MudChartParent?.ChartOptions.MaxNumYAxisTicks ?? 100; + var maxYTicks = MudChartParent?.ChartOptions.MaxNumYAxisTicks ?? 100; while (numHorizontalLines > maxYTicks) { gridYUnits *= 2; @@ -91,11 +91,11 @@ private void GenerateHorizontalGridLines(int numHorizontalLines, int lowestHoriz for (var i = 0; i < numHorizontalLines; i++) { - var y = VerticalStartSpace + i * verticalSpace; + var y = VerticalStartSpace + (i * verticalSpace); var line = new SvgPath() { Index = i, - Data = $"M {ToS(HorizontalStartSpace)} {ToS((BoundHeight - y))} L {ToS((BoundWidth - HorizontalEndSpace))} {ToS((BoundHeight - y))}" + Data = $"M {ToS(HorizontalStartSpace)} {ToS(BoundHeight - y)} L {ToS(BoundWidth - HorizontalEndSpace)} {ToS(BoundHeight - y)}" }; _horizontalLines.Add(line); @@ -117,11 +117,11 @@ private void GenerateVerticalGridLines(int numVerticalLines, double gridXUnits, for (var i = 0; i < numVerticalLines; i++) { - var x = HorizontalStartSpace + i * horizontalSpace; + var x = HorizontalStartSpace + (i * horizontalSpace); var line = new SvgPath() { Index = i, - Data = $"M {ToS(x)} {ToS((BoundHeight - VerticalStartSpace))} L {ToS(x)} {ToS(VerticalEndSpace)}" + Data = $"M {ToS(x)} {ToS(BoundHeight - VerticalStartSpace)} L {ToS(x)} {ToS(VerticalEndSpace)}" }; _verticalLines.Add(line); @@ -143,23 +143,23 @@ private void GenerateChartLines(int lowestHorizontalLine, double gridYUnits, dou for (var i = 0; i < _series.Count; i++) { - StringBuilder chartLine = new StringBuilder(); + var chartLine = new StringBuilder(); var data = _series[i].Data; (double x, double y) GetXYForDataPoint(int index) { - var x = HorizontalStartSpace + index * horizontalSpace; - var gridValue = (data[index] / gridYUnits - lowestHorizontalLine) * verticalSpace; + var x = HorizontalStartSpace + (index * horizontalSpace); + var gridValue = ((data[index] / gridYUnits) - lowestHorizontalLine) * verticalSpace; var y = BoundHeight - VerticalStartSpace - gridValue; return (x, y); } - bool interpolationEnabled = MudChartParent != null && MudChartParent.ChartOptions.InterpolationOption != InterpolationOption.Straight; + var interpolationEnabled = MudChartParent != null && MudChartParent.ChartOptions.InterpolationOption != InterpolationOption.Straight; if (interpolationEnabled) { - double[] XValues = new double[data.Length]; - double[] YValues = new double[data.Length]; + var XValues = new double[data.Length]; + var YValues = new double[data.Length]; for (var j = 0; j < data.Length; j++) (XValues[j], YValues[j]) = GetXYForDataPoint(j); @@ -180,7 +180,7 @@ private void GenerateChartLines(int lowestHorizontalLine, double gridYUnits, dou else chartLine.Append(" L "); - var x = HorizontalStartSpace + j * horizontalSpace; + var x = HorizontalStartSpace + (j * horizontalSpace); var y = interpolator.InterpolatedYs[j]; chartLine.Append(ToS(x)); chartLine.Append(' '); diff --git a/src/MudBlazor/Components/Chart/Charts/StackedBar.razor.cs b/src/MudBlazor/Components/Chart/Charts/StackedBar.razor.cs index d7959e30551a..08ac84429f5c 100644 --- a/src/MudBlazor/Components/Chart/Charts/StackedBar.razor.cs +++ b/src/MudBlazor/Components/Chart/Charts/StackedBar.razor.cs @@ -36,10 +36,10 @@ protected override void OnParametersSet() var maxY = 0.0; var numXLabels = XAxisLabels.Length; var numValues = _series.Any() ? _series.Max(x => x.Data.Length) : 0; - double[] barTopValues = new double[numValues]; + var barTopValues = new double[numValues]; foreach (var item in _series) { - int dataNumber = 0; + var dataNumber = 0; foreach (int i in item.Data) { barTopValues[dataNumber] += i; @@ -63,8 +63,8 @@ protected override void OnParametersSet() var verticalEndSpace = 25.0; var horizontalEndSpace = 30.0; - var verticalSpace = (boundHeight - verticalStartSpace - verticalEndSpace) / (numHorizontalLines); - var horizontalSpace = (boundWidth - horizontalStartSpace - horizontalEndSpace) / (numVerticalLines); + var verticalSpace = (boundHeight - verticalStartSpace - verticalEndSpace) / numHorizontalLines; + var horizontalSpace = (boundWidth - horizontalStartSpace - horizontalEndSpace) / numVerticalLines; //Horizontal Grid Lines var y = verticalStartSpace; @@ -74,11 +74,11 @@ protected override void OnParametersSet() var line = new SvgPath() { Index = counter, - Data = $"M {ToS(horizontalStartSpace)} {ToS((boundHeight - y))} L {ToS((boundWidth - horizontalEndSpace))} {ToS((boundHeight - y))}" + Data = $"M {ToS(horizontalStartSpace)} {ToS(boundHeight - y)} L {ToS(boundWidth - horizontalEndSpace)} {ToS(boundHeight - y)}" }; _horizontalLines.Add(line); - var lineValue = new SvgText() { X = (horizontalStartSpace), Y = (boundHeight - y + 5), Value = ToS(startGridY, MudChartParent?.ChartOptions.YAxisFormat) }; + var lineValue = new SvgText() { X = horizontalStartSpace, Y = (boundHeight - y + 5), Value = ToS(startGridY, MudChartParent?.ChartOptions.YAxisFormat) }; _horizontalValues.Add(lineValue); startGridY += gridYUnits; @@ -94,7 +94,7 @@ protected override void OnParametersSet() var line = new SvgPath() { Index = counter, - Data = $"M {ToS(x)} {ToS((boundHeight - verticalStartSpace))} L {ToS(x)} {ToS(verticalEndSpace)}" + Data = $"M {ToS(x)} {ToS(boundHeight - verticalStartSpace)} L {ToS(x)} {ToS(verticalEndSpace)}" }; _verticalLines.Add(line); @@ -118,18 +118,18 @@ protected override void OnParametersSet() double[] barValuesOffset = null; foreach (var item in _series) { - double gridValueX = horizontalStartSpace + 24; + var gridValueX = horizontalStartSpace + 24; if (barValuesOffset == null) { barValuesOffset = new double[item.Data.Length]; - for (int i = 0; i < item.Data.Length; i++) + for (var i = 0; i < item.Data.Length; i++) { barValuesOffset[i] = boundHeight - verticalStartSpace; } } - int dataNumber = 0; + var dataNumber = 0; foreach (var dataLine in item.Data) { var dataValue = dataLine * verticalSpace / gridYUnits; diff --git a/src/MudBlazor/Components/Chart/Interpolation/EndSlopeSpline.cs b/src/MudBlazor/Components/Chart/Interpolation/EndSlopeSpline.cs index f9908870ca2f..1e52debdbb5b 100644 --- a/src/MudBlazor/Components/Chart/Interpolation/EndSlopeSpline.cs +++ b/src/MudBlazor/Components/Chart/Interpolation/EndSlopeSpline.cs @@ -28,17 +28,17 @@ public EndSlopeSpline(double[] xs, double[] ys, public void CalcParameters(double alpha, double beta) { - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) a[i] = GivenYs[i]; - for (int i = 0; i < n - 1; i++) + for (var i = 0; i < n - 1; i++) h[i] = GivenXs[i + 1] - GivenXs[i]; m.a[0, 0] = 2.0 * h[0]; m.a[0, 1] = h[0]; - m.y[0] = 3 * ((a[1] - a[0]) / h[0] - Math.Tan(alpha * Math.PI / 180)); + m.y[0] = 3 * (((a[1] - a[0]) / h[0]) - Math.Tan(alpha * Math.PI / 180)); - for (int i = 0; i < n - 2; i++) + for (var i = 0; i < n - 2; i++) { m.a[i + 1, i] = h[i]; m.a[i + 1, i + 1] = 2.0 * (h[i] + h[i + 1]); @@ -46,30 +46,30 @@ public void CalcParameters(double alpha, double beta) m.a[i + 1, i + 2] = h[i + 1]; if ((h[i] != 0.0) && (h[i + 1] != 0.0)) - m.y[i + 1] = ((a[i + 2] - a[i + 1]) / h[i + 1] - (a[i + 1] - a[i]) / h[i]) * 3.0; + m.y[i + 1] = (((a[i + 2] - a[i + 1]) / h[i + 1]) - ((a[i + 1] - a[i]) / h[i])) * 3.0; else m.y[i + 1] = 0.0; } m.a[n - 1, n - 2] = h[n - 2]; m.a[n - 1, n - 1] = 2.0 * h[n - 2]; - m.y[n - 1] = 3.0 * (Math.Tan(beta * Math.PI / 180) - (a[n - 1] - a[n - 2]) / h[n - 2]); + m.y[n - 1] = 3.0 * (Math.Tan(beta * Math.PI / 180) - ((a[n - 1] - a[n - 2]) / h[n - 2])); if (gauss.Eliminate() == false) throw new InvalidOperationException(); gauss.Solve(); - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) { c[i] = m.x[i]; } - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) { if (h[i] != 0.0) { d[i] = 1.0 / 3.0 / h[i] * (c[i + 1] - c[i]); - b[i] = 1.0 / h[i] * (a[i + 1] - a[i]) - h[i] / 3.0 * (c[i + 1] + 2 * c[i]); + b[i] = (1.0 / h[i] * (a[i + 1] - a[i])) - (h[i] / 3.0 * (c[i + 1] + (2 * c[i]))); } } } diff --git a/src/MudBlazor/Components/Chart/Interpolation/MatrixSolver.cs b/src/MudBlazor/Components/Chart/Interpolation/MatrixSolver.cs index 30cfd7731fe2..93ae716662ab 100644 --- a/src/MudBlazor/Components/Chart/Interpolation/MatrixSolver.cs +++ b/src/MudBlazor/Components/Chart/Interpolation/MatrixSolver.cs @@ -57,7 +57,7 @@ public bool Eliminate() { if (!calcError) { - m.a[i + 1, l] = m.a[i + 1, l] * m.a[k, k] - m.a[k, l] * m.a[i + 1, k]; + m.a[i + 1, l] = (m.a[i + 1, l] * m.a[k, k]) - (m.a[k, l] * m.a[i + 1, k]); if (m.a[i + 1, l] > 10E260) { m.a[i + 1, k] = 0; @@ -65,7 +65,7 @@ public bool Eliminate() } } } - m.y[i + 1] = m.y[i + 1] * m.a[k, k] - m.y[k] * m.a[i + 1, k]; + m.y[i + 1] = (m.y[i + 1] * m.a[k, k]) - (m.y[k] * m.a[i + 1, k]); m.a[i + 1, k] = 0; } } @@ -80,7 +80,7 @@ public void Solve() { for (l = maxOrder - 1; l >= k; l--) { - m.y[k] = m.y[k] - m.x[l] * m.a[k, l]; + m.y[k] = m.y[k] - (m.x[l] * m.a[k, l]); } if (m.a[k, k] != 0) m.x[k] = m.y[k] / m.a[k, k]; diff --git a/src/MudBlazor/Components/Chart/Interpolation/NaturalSpline.cs b/src/MudBlazor/Components/Chart/Interpolation/NaturalSpline.cs index 853f042c4e8a..b27b2e7be4ed 100644 --- a/src/MudBlazor/Components/Chart/Interpolation/NaturalSpline.cs +++ b/src/MudBlazor/Components/Chart/Interpolation/NaturalSpline.cs @@ -28,15 +28,15 @@ public NaturalSpline(double[] xs, double[] ys, int resolution = 10) : base(xs, y } public void CalcParameters() { - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) a[i] = GivenYs[i]; - for (int i = 0; i < n - 1; i++) + for (var i = 0; i < n - 1; i++) h[i] = GivenXs[i + 1] - GivenXs[i]; - for (int i = 0; i < n - 2; i++) + for (var i = 0; i < n - 2; i++) { - for (int k = 0; k < n - 2; k++) + for (var k = 0; k < n - 2; k++) { m.a[i, k] = 0.0; m.y[i] = 0.0; @@ -44,7 +44,7 @@ public void CalcParameters() } } - for (int i = 0; i < n - 2; i++) + for (var i = 0; i < n - 2; i++) { if (i == 0) { @@ -60,7 +60,7 @@ public void CalcParameters() } if ((h[i] != 0.0) && (h[i + 1] != 0.0)) - m.y[i] = ((a[i + 2] - a[i + 1]) / h[i + 1] - (a[i + 1] - a[i]) / h[i]) * 3.0; + m.y[i] = (((a[i + 2] - a[i + 1]) / h[i + 1]) - ((a[i + 1] - a[i]) / h[i])) * 3.0; else m.y[i] = 0.0; } @@ -73,15 +73,15 @@ public void CalcParameters() c[0] = 0.0; c[n - 1] = 0.0; - for (int i = 1; i < n - 1; i++) + for (var i = 1; i < n - 1; i++) c[i] = m.x[i - 1]; - for (int i = 0; i < n - 1; i++) + for (var i = 0; i < n - 1; i++) { if (h[i] != 0.0) { d[i] = 1.0 / 3.0 / h[i] * (c[i + 1] - c[i]); - b[i] = 1.0 / h[i] * (a[i + 1] - a[i]) - h[i] / 3.0 * (c[i + 1] + 2 * c[i]); + b[i] = (1.0 / h[i] * (a[i + 1] - a[i])) - (h[i] / 3.0 * (c[i + 1] + (2 * c[i]))); } } } diff --git a/src/MudBlazor/Components/Chart/Interpolation/PeriodicSpline.cs b/src/MudBlazor/Components/Chart/Interpolation/PeriodicSpline.cs index 50358bc424e7..82c06d15e446 100644 --- a/src/MudBlazor/Components/Chart/Interpolation/PeriodicSpline.cs +++ b/src/MudBlazor/Components/Chart/Interpolation/PeriodicSpline.cs @@ -26,24 +26,24 @@ public PeriodicSpline(double[] xs, double[] ys, int resolution = 10) : base(xs, public void CalcParameters() { - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) a[i] = GivenYs[i]; - for (int i = 0; i < n - 1; i++) + for (var i = 0; i < n - 1; i++) h[i] = GivenXs[i + 1] - GivenXs[i]; a[n] = GivenYs[1]; h[n - 1] = h[0]; - for (int i = 0; i < n - 1; i++) - for (int k = 0; k < n - 1; k++) + for (var i = 0; i < n - 1; i++) + for (var k = 0; k < n - 1; k++) { m.a[i, k] = 0.0; m.y[i] = 0.0; m.x[i] = 0.0; } - for (int i = 0; i < n - 1; i++) + for (var i = 0; i < n - 1; i++) { if (i == 0) { @@ -58,7 +58,7 @@ public void CalcParameters() m.a[i, i + 1] = h[i + 1]; } if ((h[i] != 0.0) && (h[i + 1] != 0.0)) - m.y[i] = ((a[i + 2] - a[i + 1]) / h[i + 1] - (a[i + 1] - a[i]) / h[i]) * 3.0; + m.y[i] = (((a[i + 2] - a[i + 1]) / h[i + 1]) - ((a[i + 1] - a[i]) / h[i])) * 3.0; else m.y[i] = 0.0; } @@ -71,16 +71,16 @@ public void CalcParameters() gauss.Solve(); - for (int i = 1; i < n; i++) + for (var i = 1; i < n; i++) c[i] = m.x[i - 1]; c[0] = c[n - 1]; - for (int i = 0; i < n; i++) + for (var i = 0; i < n; i++) { if (h[i] != 0.0) { d[i] = 1.0 / 3.0 / h[i] * (c[i + 1] - c[i]); - b[i] = 1.0 / h[i] * (a[i + 1] - a[i]) - h[i] / 3.0 * (c[i + 1] + 2 * c[i]); + b[i] = (1.0 / h[i] * (a[i + 1] - a[i])) - (h[i] / 3.0 * (c[i + 1] + (2 * c[i]))); } } } diff --git a/src/MudBlazor/Components/Chart/Interpolation/SplineInterpolator.cs b/src/MudBlazor/Components/Chart/Interpolation/SplineInterpolator.cs index a50eadaf8005..560d9d787a0e 100644 --- a/src/MudBlazor/Components/Chart/Interpolation/SplineInterpolator.cs +++ b/src/MudBlazor/Components/Chart/Interpolation/SplineInterpolator.cs @@ -40,17 +40,17 @@ public SplineInterpolator(double[] xs, double[] ys, int resolution = 10) } public void Interpolate() { - int resolution = InterpolatedXs.Length / n; - for (int i = 0; i < h.Length; i++) + var resolution = InterpolatedXs.Length / n; + for (var i = 0; i < h.Length; i++) { - for (int k = 0; k < resolution; k++) + for (var k = 0; k < resolution; k++) { - double deltaX = (double)k / resolution * h[i]; - double termA = a[i]; - double termB = b[i] * deltaX; - double termC = c[i] * deltaX * deltaX; - double termD = d[i] * deltaX * deltaX * deltaX; - int interpolatedIndex = i * resolution + k; + var deltaX = (double)k / resolution * h[i]; + var termA = a[i]; + var termB = b[i] * deltaX; + var termC = c[i] * deltaX * deltaX; + var termD = d[i] * deltaX * deltaX * deltaX; + var interpolatedIndex = (i * resolution) + k; InterpolatedXs[interpolatedIndex] = deltaX + GivenXs[i]; InterpolatedYs[interpolatedIndex] = termA + termB + termC + termD; } @@ -59,9 +59,9 @@ public void Interpolate() // After interpolation the last several values of the interpolated arrays // contain uninitialized data. This section identifies the values which are // populated with values and copies just the useful data into new arrays. - int pointsToKeep = resolution * (n - 1) + 1; - double[] interpolatedXsCopy = new double[pointsToKeep]; - double[] interpolatedYsCopy = new double[pointsToKeep]; + var pointsToKeep = (resolution * (n - 1)) + 1; + var interpolatedXsCopy = new double[pointsToKeep]; + var interpolatedYsCopy = new double[pointsToKeep]; Array.Copy(InterpolatedXs, 0, interpolatedXsCopy, 0, pointsToKeep - 1); Array.Copy(InterpolatedYs, 0, interpolatedYsCopy, 0, pointsToKeep - 1); InterpolatedXs = interpolatedXsCopy; @@ -73,12 +73,12 @@ public void Interpolate() public double Integrate() { double integral = 0; - for (int i = 0; i < h.Length; i++) + for (var i = 0; i < h.Length; i++) { - double termA = a[i] * h[i]; - double termB = b[i] * Math.Pow(h[i], 2) / 2.0; - double termC = c[i] * Math.Pow(h[i], 3) / 3.0; - double termD = d[i] * Math.Pow(h[i], 4) / 4.0; + var termA = a[i] * h[i]; + var termB = b[i] * Math.Pow(h[i], 2) / 2.0; + var termC = c[i] * Math.Pow(h[i], 3) / 3.0; + var termD = d[i] * Math.Pow(h[i], 4) / 4.0; integral += termA + termB + termC + termD; } return integral; diff --git a/src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs b/src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs index 935cd7881b2e..3ec821c7bb3e 100644 --- a/src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs +++ b/src/MudBlazor/Components/ColorPicker/MudColorPicker.razor.cs @@ -76,7 +76,7 @@ public bool DisableAlpha { _disableAlpha = value; - if (value == true) + if (value) { Value = Value.SetAlpha(1.0); } @@ -332,9 +332,9 @@ private void UpdateBaseColor() var valueInDeg = (int)_value.H - (index * 60); var value = (int)(MathExtensions.Map(0, 60, 0, 255, valueInDeg)); - var section = _rgbToHueMapper[index]; + var (r, g, b, dominantColorPart) = _rgbToHueMapper[index]; - _baseColor = new(section.r(value), section.g(value), section.b(value), 255); + _baseColor = new(r(value), g(value), b(value), 255); } private void UpdateColorBaseOnSelection() @@ -345,7 +345,7 @@ private void UpdateColorBaseOnSelection() var g_x = 255 - (int)((255 - _baseColor.G) * x); var b_x = 255 - (int)((255 - _baseColor.B) * x); - var y = 1.0 - _selectorY / _maxY; + var y = 1.0 - (_selectorY / _maxY); var r = r_x * y; var g = g_x * y; @@ -366,9 +366,9 @@ private void UpdateColorSelectorBasedOnRgb() index = 5; } - var section = _rgbToHueMapper[index]; + var (r, g, b, dominantColorPart) = _rgbToHueMapper[index]; - var colorValues = section.dominantColorPart switch + var colorValues = dominantColorPart switch { "rb" => (_value.R, _value.B), "rg" => (_value.R, _value.G), @@ -427,8 +427,8 @@ private void OnMouseOver(MouseEventArgs e) private void SetSelectorBasedOnMouseEvents(MouseEventArgs e, bool offsetIsAbsolute) { - _selectorX = (offsetIsAbsolute == true ? e.OffsetX : (e.OffsetX - _selctorSize / 2.0) + _selectorX).EnsureRange(_maxX); - _selectorY = (offsetIsAbsolute == true ? e.OffsetY : (e.OffsetY - _selctorSize / 2.0) + _selectorY).EnsureRange(_maxY); + _selectorX = (offsetIsAbsolute ? e.OffsetX : (e.OffsetX - (_selctorSize / 2.0)) + _selectorX).EnsureRange(_maxX); + _selectorY = (offsetIsAbsolute ? e.OffsetY : (e.OffsetY - (_selctorSize / 2.0)) + _selectorY).EnsureRange(_maxY); } #endregion @@ -528,7 +528,7 @@ protected override async Task OnPickerClosedAsync() #region helper private string GetSelectorLocation() => $"translate({Math.Round(_selectorX, 2).ToString(CultureInfo.InvariantCulture)}px, {Math.Round(_selectorY, 2).ToString(CultureInfo.InvariantCulture)}px);"; - private string GetColorTextValue() => (DisableAlpha == true || _activeColorPickerView is ColorPickerView.Palette or ColorPickerView.GridCompact) ? _value.ToString(MudColorOutputFormats.Hex) : _value.ToString(MudColorOutputFormats.HexA); + private string GetColorTextValue() => (DisableAlpha || _activeColorPickerView is ColorPickerView.Palette or ColorPickerView.GridCompact) ? _value.ToString(MudColorOutputFormats.Hex) : _value.ToString(MudColorOutputFormats.HexA); private int GetHexColorInputMaxLength() => DisableAlpha ? 7 : 9; private EventCallback GetEventCallback() => EventCallback.Factory.Create(this, () => CloseAsync()); @@ -547,7 +547,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); - if (firstRender == true) + if (firstRender) { if (PickerVariant == PickerVariant.Static) { @@ -555,7 +555,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) } } - if (_attachedMouseEvent == true) + if (_attachedMouseEvent) { _attachedMouseEvent = false; await AddMouseOverEventAsync(); @@ -564,7 +564,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) private async Task AddMouseOverEventAsync() { - if (DisableDragEffect == true) { return; } + if (DisableDragEffect) { return; } if (_throttledEventManager == null) { diff --git a/src/MudBlazor/Components/DataGrid/MudDataGrid.razor.cs b/src/MudBlazor/Components/DataGrid/MudDataGrid.razor.cs index 6f47aa81e575..87e6390d2bc8 100644 --- a/src/MudBlazor/Components/DataGrid/MudDataGrid.razor.cs +++ b/src/MudBlazor/Components/DataGrid/MudDataGrid.razor.cs @@ -67,7 +67,7 @@ public partial class MudDataGrid : MudComponentBase protected string _tableStyle => new StyleBuilder() .AddStyle("height", Height, !string.IsNullOrWhiteSpace(Height)) - .AddStyle("width", "max-content", when: (HorizontalScrollbar || ColumnResizeMode == ResizeMode.Container)) + .AddStyle("width", "max-content", when: HorizontalScrollbar || ColumnResizeMode == ResizeMode.Container) .AddStyle("overflow", "clip", when: (HorizontalScrollbar || ColumnResizeMode == ResizeMode.Container) && hasStickyColumns) .AddStyle("display", "block", when: HorizontalScrollbar) .Build(); @@ -145,7 +145,7 @@ protected int numPages private static void Swap(List list, int indexA, int indexB) { - TItem tmp = list[indexA]; + var tmp = list[indexA]; list[indexA] = list[indexB]; list[indexB] = tmp; } diff --git a/src/MudBlazor/Components/DataGrid/MudDataGridPager.razor.cs b/src/MudBlazor/Components/DataGrid/MudDataGridPager.razor.cs index b62d4fe4cc8f..30375ccf4627 100644 --- a/src/MudBlazor/Components/DataGrid/MudDataGridPager.razor.cs +++ b/src/MudBlazor/Components/DataGrid/MudDataGridPager.razor.cs @@ -43,7 +43,7 @@ public partial class MudDataGridPager : MudComponentBase, IDisposable [Parameter] public string RowsPerPageString { get; set; } = "Rows per page:"; private string Info => DataGrid == null ? "DataGrid==null" : InfoFormat - .Replace("{first_item}", $"{DataGrid?.CurrentPage * DataGrid.RowsPerPage + 1}") + .Replace("{first_item}", $"{(DataGrid?.CurrentPage * DataGrid.RowsPerPage) + 1}") .Replace("{last_item}", $"{Math.Min((DataGrid.CurrentPage + 1) * DataGrid.RowsPerPage, DataGrid.GetFilteredItemsCount())}") .Replace("{all_items}", $"{DataGrid.GetFilteredItemsCount()}"); diff --git a/src/MudBlazor/Components/DatePicker/MudBaseDatePicker.razor.cs b/src/MudBlazor/Components/DatePicker/MudBaseDatePicker.razor.cs index c10df7646339..286bd9ba21ec 100644 --- a/src/MudBlazor/Components/DatePicker/MudBaseDatePicker.razor.cs +++ b/src/MudBlazor/Components/DatePicker/MudBaseDatePicker.razor.cs @@ -234,9 +234,9 @@ public Func IsDateDisabledFunc protected override async Task OnPickerOpenedAsync() { await base.OnPickerOpenedAsync(); - if (Editable == true && Text != null) + if (Editable && Text != null) { - DateTime? a = Converter.Get(Text); + var a = Converter.Get(Text); if (a.HasValue) { a = new DateTime(a.Value.Year, a.Value.Month, 1); @@ -626,7 +626,7 @@ private int GetCalendarDayOfMonth(DateTime date) private ValueTask HandleMouseoverOnPickerCalendarDayButton(int tempId) { - return this.JsApiService.UpdateStyleProperty(_mudPickerCalendarContentElementId, "--selected-day", tempId); + return JsApiService.UpdateStyleProperty(_mudPickerCalendarContentElementId, "--selected-day", tempId); } } } diff --git a/src/MudBlazor/Components/DatePicker/MudDatePicker.cs b/src/MudBlazor/Components/DatePicker/MudDatePicker.cs index 3342385bc9ea..0ec3153a675c 100644 --- a/src/MudBlazor/Components/DatePicker/MudDatePicker.cs +++ b/src/MudBlazor/Components/DatePicker/MudDatePicker.cs @@ -195,7 +195,7 @@ public override async Task ClearAsync(bool close = true) _selectedDate = null; await SetDateAsync(null, true); - if (AutoClose == true) + if (AutoClose) { await CloseAsync(false); } @@ -245,11 +245,11 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ar { IsOpen = true; } - else if (args.AltKey == true) + else if (args.AltKey) { IsOpen = false; } - else if (args.ShiftKey == true) + else if (args.ShiftKey) { } @@ -263,7 +263,7 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ar { IsOpen = true; } - else if (args.ShiftKey == true) + else if (args.ShiftKey) { } diff --git a/src/MudBlazor/Components/Dialog/MudDialogInstance.razor.cs b/src/MudBlazor/Components/Dialog/MudDialogInstance.razor.cs index 1e0dec3aa79e..b184712ce012 100644 --- a/src/MudBlazor/Components/Dialog/MudDialogInstance.razor.cs +++ b/src/MudBlazor/Components/Dialog/MudDialogInstance.razor.cs @@ -123,9 +123,8 @@ public void SetTitle(string title) } /// - /// Close and return null. - /// - /// This is a shorthand of Close(DialogResult.Ok((object)null)); + /// Close and return null. + /// This is a shorthand of Close(DialogResult.Ok((object)null)); /// public void Close() { @@ -133,9 +132,8 @@ public void Close() } /// - /// Close with dialog result. - /// - /// Usage: Close(DialogResult.Ok(returnValue)) + /// Close with dialog result. + /// Usage: Close(DialogResult.Ok(returnValue)) /// public void Close(DialogResult dialogResult) { @@ -143,9 +141,8 @@ public void Close(DialogResult dialogResult) } /// - /// Close and directly pass a return value. - /// - /// This is a shorthand for Close(DialogResult.Ok(returnValue)) + /// Close and directly pass a return value. + /// This is a shorthand for Close(DialogResult.Ok(returnValue)) /// /// /// diff --git a/src/MudBlazor/Components/Form/MudForm.razor.cs b/src/MudBlazor/Components/Form/MudForm.razor.cs index 19c512ed76a5..97d3c41b7aeb 100644 --- a/src/MudBlazor/Components/Form/MudForm.razor.cs +++ b/src/MudBlazor/Components/Form/MudForm.razor.cs @@ -315,7 +315,7 @@ public void ResetValidation() /// public void ResetTouched() { - this._touched = false; + _touched = false; } protected override Task OnAfterRenderAsync(bool firstRender) diff --git a/src/MudBlazor/Components/Highlighter/Splitter.cs b/src/MudBlazor/Components/Highlighter/Splitter.cs index aced369c1383..a7796a33ed27 100644 --- a/src/MudBlazor/Components/Highlighter/Splitter.cs +++ b/src/MudBlazor/Components/Highlighter/Splitter.cs @@ -43,7 +43,7 @@ public static Memory GetFragments(string? text, builder.Append("((?:"); //this becomes true if `AppendPattern` was called at least once. - bool hasAtLeastOnePattern = false; + var hasAtLeastOnePattern = false; if (!string.IsNullOrEmpty(highlightedText)) { AppendPattern(highlightedText); diff --git a/src/MudBlazor/Components/Input/MudInput.razor.cs b/src/MudBlazor/Components/Input/MudInput.razor.cs index 9010edbefd50..3f38ba8e4bcd 100644 --- a/src/MudBlazor/Components/Input/MudInput.razor.cs +++ b/src/MudBlazor/Components/Input/MudInput.razor.cs @@ -24,9 +24,9 @@ public partial class MudInput : MudBaseInput, IAsyncDisposable protected string ClearButtonClassname => new CssBuilder() .AddClass("me-n1", Adornment == Adornment.End && HideSpinButtons == false) - .AddClass("mud-icon-button-edge-end", Adornment == Adornment.End && HideSpinButtons == true) + .AddClass("mud-icon-button-edge-end", Adornment == Adornment.End && HideSpinButtons) .AddClass("me-6", Adornment != Adornment.End && HideSpinButtons == false) - .AddClass("mud-icon-button-edge-margin-end", Adornment != Adornment.End && HideSpinButtons == true) + .AddClass("mud-icon-button-edge-margin-end", Adornment != Adornment.End && HideSpinButtons) .Build(); /// diff --git a/src/MudBlazor/Components/Mask/MudMask.razor.cs b/src/MudBlazor/Components/Mask/MudMask.razor.cs index 08261d6b7345..ebc33a9b0eb0 100644 --- a/src/MudBlazor/Components/Mask/MudMask.razor.cs +++ b/src/MudBlazor/Components/Mask/MudMask.razor.cs @@ -15,7 +15,7 @@ namespace MudBlazor { - public partial class MudMask : MudBaseInput, IDisposable + public partial class MudMask : MudBaseInput { public MudMask() { @@ -434,7 +434,7 @@ protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (disposing == true) + if (disposing) { if (_keyInterceptor != null) { diff --git a/src/MudBlazor/Components/MessageBox/MudMessageBox.razor.cs b/src/MudBlazor/Components/MessageBox/MudMessageBox.razor.cs index d47600215dc1..c8ccf579661a 100644 --- a/src/MudBlazor/Components/MessageBox/MudMessageBox.razor.cs +++ b/src/MudBlazor/Components/MessageBox/MudMessageBox.razor.cs @@ -176,7 +176,7 @@ public bool IsVisible [nameof(YesText)] = YesText, [nameof(YesButton)] = YesButton, }; - _reference = await DialogService.ShowAsync(parameters: parameters, options: options, title: Title); + _reference = await DialogService.ShowAsync(title: Title, parameters: parameters, options: options); var result = await _reference.Result; if (result.Canceled || result.Data is not bool data) { diff --git a/src/MudBlazor/Components/NumericField/MudNumericField.razor.cs b/src/MudBlazor/Components/NumericField/MudNumericField.razor.cs index 3401163b996b..4fb9b2ee146c 100644 --- a/src/MudBlazor/Components/NumericField/MudNumericField.razor.cs +++ b/src/MudBlazor/Components/NumericField/MudNumericField.razor.cs @@ -20,7 +20,7 @@ public partial class MudNumericField : MudDebouncedInput private IKeyInterceptor _keyInterceptor; private Comparer _comparer = new(CultureInfo.InvariantCulture); - public MudNumericField() : base() + public MudNumericField() { Validation = new Func>(ValidateInput); #region parameters default depending on T @@ -205,12 +205,12 @@ private async Task Change(double factor = 1) private T GetNextValue(double factor) { if (typeof(T) == typeof(decimal) || typeof(T) == typeof(decimal?)) - return (T)(object)Convert.ToDecimal(FromDecimal(Value) + FromDecimal(Step) * (decimal)factor); + return (T)(object)Convert.ToDecimal(FromDecimal(Value) + (FromDecimal(Step) * (decimal)factor)); if (typeof(T) == typeof(long) || typeof(T) == typeof(long?)) - return (T)(object)Convert.ToInt64(FromInt64(Value) + FromInt64(Step) * factor); + return (T)(object)Convert.ToInt64(FromInt64(Value) + (FromInt64(Step) * factor)); if (typeof(T) == typeof(ulong) || typeof(T) == typeof(ulong?)) - return (T)(object)Convert.ToUInt64(FromUInt64(Value) + FromUInt64(Step) * factor); - return Num.To(Num.From(Value) + Num.From(Step) * factor); + return (T)(object)Convert.ToUInt64(FromUInt64(Value) + (FromUInt64(Step) * factor)); + return Num.To(Num.From(Value) + (Num.From(Step) * factor)); } /// @@ -393,11 +393,12 @@ public T Step public override InputMode InputMode { get; set; } = InputMode.numeric; /// + /// /// The pattern attribute, when specified, is a regular expression which the input's value must match in order for the value to pass constraint validation. It must be a valid JavaScript regular expression /// Defaults to [0-9,.\-] /// To get a numerical keyboard on safari, use the pattern. The default pattern should achieve numerical keyboard. - /// - /// Note: this pattern is also used to prevent all input except numbers and allowed characters. So for instance to allow only numbers, no signs and no commas you might change it to to [0-9.] + /// + /// Note: this pattern is also used to prevent all input except numbers and allowed characters. So for instance to allow only numbers, no signs and no commas you might change it to [0-9.] /// [Parameter] public override string Pattern { get; set; } = @"[0-9,.\-]"; @@ -432,7 +433,7 @@ protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (disposing == true) + if (disposing) { _keyInterceptor?.Dispose(); } diff --git a/src/MudBlazor/Components/PageContentNavigation/MudPageContentNavigation.razor.cs b/src/MudBlazor/Components/PageContentNavigation/MudPageContentNavigation.razor.cs index e9d1e35f2638..8f7762db0457 100644 --- a/src/MudBlazor/Components/PageContentNavigation/MudPageContentNavigation.razor.cs +++ b/src/MudBlazor/Components/PageContentNavigation/MudPageContentNavigation.razor.cs @@ -130,8 +130,8 @@ public void AddSection(MudPageContentSection section, bool forceUpdate) { _sections.Add(section); - int diffRootLevel = 1_000_000; - int counter = 0; + var diffRootLevel = 1_000_000; + var counter = 0; foreach (var item in _sections.Where(x => x.Parent is null)) { item.SetLevelStructure(counter, diffRootLevel); diff --git a/src/MudBlazor/Components/PageContentNavigation/MudPageContentSection.cs b/src/MudBlazor/Components/PageContentNavigation/MudPageContentSection.cs index 4f227fad3758..9792ff8dc5b8 100644 --- a/src/MudBlazor/Components/PageContentNavigation/MudPageContentSection.cs +++ b/src/MudBlazor/Components/PageContentNavigation/MudPageContentSection.cs @@ -68,8 +68,8 @@ public MudPageContentSection(string title, string id, int level, MudPageContentS internal void SetLevelStructure(int counter, int diff) { LevelSortingValue = counter; - int levelDiff = diff / 10; - int value = counter + levelDiff; + var levelDiff = diff / 10; + var value = counter + levelDiff; foreach (var item in _children) { item.SetLevelStructure(value, levelDiff); diff --git a/src/MudBlazor/Components/Pagination/MudPagination.razor.cs b/src/MudBlazor/Components/Pagination/MudPagination.razor.cs index 480660dcd9b0..993dbf077af7 100644 --- a/src/MudBlazor/Components/Pagination/MudPagination.razor.cs +++ b/src/MudBlazor/Components/Pagination/MudPagination.razor.cs @@ -227,10 +227,10 @@ public int Selected private IEnumerable GeneratePagination() { //return array {1, ..., Count} if Count is small - if (Count <= 4 || Count <= 2 * BoundaryCount + MiddleCount + 2) + if (Count <= 4 || Count <= (2 * BoundaryCount) + MiddleCount + 2) return Enumerable.Range(1, Count).ToArray(); - var length = 2 * BoundaryCount + MiddleCount + 2; + var length = (2 * BoundaryCount) + MiddleCount + 2; var pages = new int[length]; //set start boundary items, e.g. if BoundaryCount == 3 => [1, 2, 3, ...] @@ -247,12 +247,12 @@ private IEnumerable GeneratePagination() //calculate start value for middle items int startValue; - if (Selected <= BoundaryCount + MiddleCount / 2 + 1) + if (Selected <= BoundaryCount + (MiddleCount / 2) + 1) startValue = BoundaryCount + 2; - else if (Selected >= Count - BoundaryCount - MiddleCount / 2) + else if (Selected >= Count - BoundaryCount - (MiddleCount / 2)) startValue = Count - BoundaryCount - MiddleCount; else - startValue = Selected - MiddleCount / 2; + startValue = Selected - (MiddleCount / 2); //set middle items, e.g. if MiddleCount == 3 and Selected == 5 and Count == 11 => [..., 4, 5, 6, ...] for (var i = 0; i < MiddleCount; i++) @@ -261,10 +261,10 @@ private IEnumerable GeneratePagination() } //set start delimiter "..." when selected page is far enough to the end, dots are represented as -1 - pages[BoundaryCount] = (BoundaryCount + MiddleCount / 2 + 1 < Selected) ? -1 : BoundaryCount + 1; + pages[BoundaryCount] = (BoundaryCount + (MiddleCount / 2) + 1 < Selected) ? -1 : BoundaryCount + 1; //set end delimiter "..." when selected page is far enough to the start, dots are represented as -1 - pages[length - BoundaryCount - 1] = (Count - BoundaryCount - MiddleCount / 2 > Selected) ? -1 : Count - BoundaryCount; + pages[length - BoundaryCount - 1] = (Count - BoundaryCount - (MiddleCount / 2) > Selected) ? -1 : Count - BoundaryCount; //remove ellipsis if difference is small enough, e.g convert [..., 5 , -1 , 7, ...] to [..., 5, 6, 7, ...] for (var i = 0; i < length - 2; i++) diff --git a/src/MudBlazor/Components/Picker/MudPicker.razor.cs b/src/MudBlazor/Components/Picker/MudPicker.razor.cs index f663458707bc..3d5a96d4f503 100644 --- a/src/MudBlazor/Components/Picker/MudPicker.razor.cs +++ b/src/MudBlazor/Components/Picker/MudPicker.razor.cs @@ -553,7 +553,7 @@ protected internal virtual async Task OnHandleKeyDownAsync(KeyboardEventArgs arg switch (args.Key) { case "Backspace": - if (args.CtrlKey == true && args.ShiftKey == true) + if (args.CtrlKey && args.ShiftKey) { await ClearAsync(); _value = default; diff --git a/src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs b/src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs index 12d2750a16b5..94ba9e671386 100644 --- a/src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs +++ b/src/MudBlazor/Components/Progress/MudProgressCircular.razor.cs @@ -88,7 +88,7 @@ private int ToSvgValue(double value) // calculate fraction, which is a value between 0 and 1 var fraction = (minValue - Min) / (Max - Min); // now project into the range of the SVG value (126 .. 0) - return (int)Math.Round(_magicNumber - _magicNumber * fraction); + return (int)Math.Round(_magicNumber - (_magicNumber * fraction)); } } } diff --git a/src/MudBlazor/Components/Radio/MudRadio.razor.cs b/src/MudBlazor/Components/Radio/MudRadio.razor.cs index e31aa8f635e8..497c889a86c0 100644 --- a/src/MudBlazor/Components/Radio/MudRadio.razor.cs +++ b/src/MudBlazor/Components/Radio/MudRadio.razor.cs @@ -26,7 +26,7 @@ public partial class MudRadio : MudComponentBase, IDisposable protected string ButtonClassname => new CssBuilder("mud-button-root mud-icon-button") .AddClass($"mud-ripple mud-ripple-radio", !DisableRipple && !Disabled && !(MudRadioGroup?.GetDisabledState() ?? false) && !(MudRadioGroup?.GetReadOnlyState() ?? false)) - .AddClass($"mud-{Color.ToDescriptionString()}-text hover:mud-{Color.ToDescriptionString()}-hover", UnCheckedColor == null || (UnCheckedColor != null && Checked == true)) + .AddClass($"mud-{Color.ToDescriptionString()}-text hover:mud-{Color.ToDescriptionString()}-hover", UnCheckedColor == null || (UnCheckedColor != null && Checked)) .AddClass($"mud-{UnCheckedColor?.ToDescriptionString()}-text hover:mud-{UnCheckedColor?.ToDescriptionString()}-hover", UnCheckedColor != null && Checked == false) .AddClass($"mud-radio-dense", Dense) .AddClass($"mud-disabled", IsDisabled) diff --git a/src/MudBlazor/Components/ScrollToTop/MudScrollToTop.razor.cs b/src/MudBlazor/Components/ScrollToTop/MudScrollToTop.razor.cs index 367dcb4ece8e..ee92b10f00b7 100644 --- a/src/MudBlazor/Components/ScrollToTop/MudScrollToTop.razor.cs +++ b/src/MudBlazor/Components/ScrollToTop/MudScrollToTop.razor.cs @@ -117,7 +117,7 @@ private async void ScrollListener_OnScroll(object? sender, ScrollEventArgs e) await InvokeAsync(StateHasChanged); } - if (topOffset < TopOffset && Visible == true) + if (topOffset < TopOffset && Visible) { Visible = false; await InvokeAsync(StateHasChanged); diff --git a/src/MudBlazor/Components/Select/MudSelect.razor.cs b/src/MudBlazor/Components/Select/MudSelect.razor.cs index ddc2781f7773..33407b422076 100644 --- a/src/MudBlazor/Components/Select/MudSelect.razor.cs +++ b/src/MudBlazor/Components/Select/MudSelect.razor.cs @@ -57,7 +57,7 @@ private async Task SelectAdjacentItem(int direction) index = 0; MudSelectItem item = null; // the loop allows us to jump over disabled items until we reach the next non-disabled one - for (int i = 0; i < _items.Count; i++) + for (var i = 0; i < _items.Count; i++) { index += direction; if (index < 0) @@ -387,7 +387,7 @@ protected bool CanRenderValue return false; if (!_shadowLookup.TryGetValue(Value, out var item)) return false; - return (item.ChildContent != null); + return item.ChildContent != null; } } @@ -707,7 +707,7 @@ public async Task CloseMenu(bool focusAgain = true) { _isOpen = false; UpdateIcon(); - if (focusAgain == true) + if (focusAgain) { StateHasChanged(); await OnBlur.InvokeAsync(new FocusEventArgs()); @@ -877,7 +877,7 @@ internal async void HandleKeyDown(KeyboardEventArgs obj) await CloseMenu(false); break; case "ArrowUp": - if (obj.AltKey == true) + if (obj.AltKey) { await CloseMenu(); break; @@ -893,7 +893,7 @@ internal async void HandleKeyDown(KeyboardEventArgs obj) break; } case "ArrowDown": - if (obj.AltKey == true) + if (obj.AltKey) { await OpenMenu(); break; @@ -950,7 +950,7 @@ internal async void HandleKeyDown(KeyboardEventArgs obj) } case "a": case "A": - if (obj.CtrlKey == true) + if (obj.CtrlKey) { if (MultiSelection) { @@ -997,7 +997,7 @@ private async Task SelectAllClickAsync() else _selectAllChecked = true; // Define the items selection - if (_selectAllChecked.Value == true) + if (_selectAllChecked.Value) await SelectAllItems(); else await Clear(); @@ -1060,7 +1060,7 @@ protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (disposing == true) + if (disposing) { if (_keyInterceptor != null) { diff --git a/src/MudBlazor/Components/Select/MudSelectItem.razor.cs b/src/MudBlazor/Components/Select/MudSelectItem.razor.cs index 1b313f613e99..4e7e6994b859 100644 --- a/src/MudBlazor/Components/Select/MudSelectItem.razor.cs +++ b/src/MudBlazor/Components/Select/MudSelectItem.razor.cs @@ -11,7 +11,7 @@ namespace MudBlazor /// public partial class MudSelectItem : MudBaseSelectItem, IDisposable { - private String GetCssClasses() => new CssBuilder() + private string GetCssClasses() => new CssBuilder() .AddClass(Class) .Build(); @@ -33,7 +33,7 @@ internal IMudSelect IMudSelect _parent.CheckGenericTypeMatch(this); if (MudSelect == null) return; - bool isSelected = MudSelect.Add(this); + var isSelected = MudSelect.Add(this); if (_parent.MultiSelection) { MudSelect.SelectionChangedFromOutside += OnUpdateSelectionStateFromOutside; diff --git a/src/MudBlazor/Components/Snackbar/SnackbarService.cs b/src/MudBlazor/Components/Snackbar/SnackbarService.cs index 9f04021f15d9..9c010070ae7d 100644 --- a/src/MudBlazor/Components/Snackbar/SnackbarService.cs +++ b/src/MudBlazor/Components/Snackbar/SnackbarService.cs @@ -15,7 +15,7 @@ namespace MudBlazor { /// - public class SnackbarService : ISnackbar, IDisposable + public class SnackbarService : ISnackbar { public SnackbarConfiguration Configuration { get; } public event Action OnSnackbarsUpdated; diff --git a/src/MudBlazor/Components/Table/MudTFootRow.razor.cs b/src/MudBlazor/Components/Table/MudTFootRow.razor.cs index b4bd061a3f98..b22f59f156fe 100644 --- a/src/MudBlazor/Components/Table/MudTFootRow.razor.cs +++ b/src/MudBlazor/Components/Table/MudTFootRow.razor.cs @@ -20,12 +20,12 @@ public partial class MudTFootRow : MudComponentBase [Parameter] public bool IsCheckable { get; set; } /// - /// Specify behavior in case the table is multi-select mode. If set to true, it won't render an additional empty column. + /// Specify behavior in case the table is multi-select mode. If set to true, it won't render an additional empty column. /// [Parameter] public bool IgnoreCheckbox { get; set; } /// - /// Specify behavior in case the table is editable. If set to true, it won't render an additional empty column. + /// Specify behavior in case the table is editable. If set to true, it won't render an additional empty column. /// [Parameter] public bool IgnoreEditable { get; set; } diff --git a/src/MudBlazor/Components/Table/MudTHeadRow.razor.cs b/src/MudBlazor/Components/Table/MudTHeadRow.razor.cs index 1ecfee9d6778..23e858f9f4c9 100644 --- a/src/MudBlazor/Components/Table/MudTHeadRow.razor.cs +++ b/src/MudBlazor/Components/Table/MudTHeadRow.razor.cs @@ -20,12 +20,12 @@ public partial class MudTHeadRow : MudComponentBase [Parameter] public bool IsCheckable { get; set; } /// - /// Specify behavior in case the table is multi-select mode. If set to true, it won't render an additional empty column. + /// Specify behavior in case the table is multi-select mode. If set to true, it won't render an additional empty column. /// [Parameter] public bool IgnoreCheckbox { get; set; } /// - /// Specify behavior in case the table is editable. If set to true, it won't render an additional empty column. + /// Specify behavior in case the table is editable. If set to true, it won't render an additional empty column. /// [Parameter] public bool IgnoreEditable { get; set; } diff --git a/src/MudBlazor/Components/Table/MudTable.razor.cs b/src/MudBlazor/Components/Table/MudTable.razor.cs index 59f272b179da..74f9f7995c9d 100644 --- a/src/MudBlazor/Components/Table/MudTable.razor.cs +++ b/src/MudBlazor/Components/Table/MudTable.razor.cs @@ -509,7 +509,7 @@ public override TableContext TableContext get { Context.Table = this; - Context.TableStateHasChanged = this.StateHasChanged; + Context.TableStateHasChanged = StateHasChanged; return Context; } } diff --git a/src/MudBlazor/Components/Table/MudTablePager.razor.cs b/src/MudBlazor/Components/Table/MudTablePager.razor.cs index 26e43fc73f62..36897751267f 100644 --- a/src/MudBlazor/Components/Table/MudTablePager.razor.cs +++ b/src/MudBlazor/Components/Table/MudTablePager.razor.cs @@ -73,7 +73,7 @@ private string Info return Table == null ? "Table==null" : InfoFormat - .Replace("{first_item}", $"{(filteredItemsCount == 0 ? 0 : Table?.CurrentPage * Table.RowsPerPage + 1)}") + .Replace("{first_item}", $"{(filteredItemsCount == 0 ? 0 : (Table?.CurrentPage * Table.RowsPerPage) + 1)}") .Replace("{last_item}", $"{Math.Min((Table.CurrentPage + 1) * Table.RowsPerPage, filteredItemsCount)}") .Replace("{all_items}", $"{filteredItemsCount}"); } diff --git a/src/MudBlazor/Components/Tabs/MudTabs.razor.cs b/src/MudBlazor/Components/Tabs/MudTabs.razor.cs index 71061f4ab0dd..5c590028fef3 100644 --- a/src/MudBlazor/Components/Tabs/MudTabs.razor.cs +++ b/src/MudBlazor/Components/Tabs/MudTabs.razor.cs @@ -346,7 +346,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) public async ValueTask DisposeAsync() { - if (_isDisposed == true) + if (_isDisposed) return; _isDisposed = true; _resizeObserver.OnResized -= OnResized; @@ -370,7 +370,7 @@ internal void AddPanel(MudTabPanel tabPanel) internal async Task SetPanelRef(ElementReference reference) { - if (_isRendered == true && _resizeObserver.IsElementObserved(reference) == false) + if (_isRendered && _resizeObserver.IsElementObserved(reference) == false) { await _resizeObserver.Observe(reference); Rerender(); @@ -742,7 +742,7 @@ private void CenterScrollPositionAroundSelectedItem() } } - MudTabPanel panelToStart = ActivePanel; + var panelToStart = ActivePanel; var length = GetPanelLength(panelToStart); if (length >= _toolbarContentSize) { diff --git a/src/MudBlazor/Components/Tabs/TabHeaderPosition.cs b/src/MudBlazor/Components/Tabs/TabHeaderPosition.cs index d1feb43bdb48..1b136ede652f 100644 --- a/src/MudBlazor/Components/Tabs/TabHeaderPosition.cs +++ b/src/MudBlazor/Components/Tabs/TabHeaderPosition.cs @@ -7,7 +7,7 @@ namespace MudBlazor public enum TabHeaderPosition { /// - /// Additional content is placed after the the first tab + /// Additional content is placed after the first tab /// [Description("after")] After, diff --git a/src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs b/src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs index 5d5b30c5943f..31f39353c6d8 100644 --- a/src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs +++ b/src/MudBlazor/Components/TimePicker/MudTimePicker.razor.cs @@ -389,8 +389,8 @@ private double GetDeg() private string GetTransform(double angle, double radius, double offsetX, double offsetY) { angle = angle / 180 * Math.PI; - var x = (Math.Sin(angle) * radius + offsetX).ToString("F3", CultureInfo.InvariantCulture); - var y = ((Math.Cos(angle) + 1) * radius + offsetY).ToString("F3", CultureInfo.InvariantCulture); + var x = ((Math.Sin(angle) * radius) + offsetX).ToString("F3", CultureInfo.InvariantCulture); + var y = (((Math.Cos(angle) + 1) * radius) + offsetY).ToString("F3", CultureInfo.InvariantCulture); return $"transform: translate({x}px, {y}px);"; } @@ -552,7 +552,7 @@ private int RoundToStepInterval(int value) if (MinuteSelectionStep > 1) // Ignore if step is less than or equal to 1 { var interval = MinuteSelectionStep % 60; - value = (value + interval / 2) / interval * interval; + value = (value + (interval / 2)) / interval * interval; if (value == 60) // For when it rounds up to 60 { value = 0; @@ -585,11 +585,11 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ob case "ArrowRight": if (IsOpen) { - if (obj.CtrlKey == true) + if (obj.CtrlKey) { await ChangeHourAsync(1); } - else if (obj.ShiftKey == true) + else if (obj.ShiftKey) { if (_timeSet.Minute > 55) { @@ -610,11 +610,11 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ob case "ArrowLeft": if (IsOpen) { - if (obj.CtrlKey == true) + if (obj.CtrlKey) { await ChangeHourAsync(-1); } - else if (obj.ShiftKey == true) + else if (obj.ShiftKey) { if (_timeSet.Minute < 5) { @@ -637,11 +637,11 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ob { IsOpen = true; } - else if (obj.AltKey == true) + else if (obj.AltKey) { IsOpen = false; } - else if (obj.ShiftKey == true) + else if (obj.ShiftKey) { await ChangeHourAsync(5); } @@ -655,7 +655,7 @@ protected internal override async Task OnHandleKeyDownAsync(KeyboardEventArgs ob { IsOpen = true; } - else if (obj.ShiftKey == true) + else if (obj.ShiftKey) { await ChangeHourAsync(-5); } diff --git a/src/MudBlazor/Extensions/MathExtensions.cs b/src/MudBlazor/Extensions/MathExtensions.cs index 95bd9ad2f42d..58dae2c3e72c 100644 --- a/src/MudBlazor/Extensions/MathExtensions.cs +++ b/src/MudBlazor/Extensions/MathExtensions.cs @@ -4,6 +4,6 @@ public static class MathExtensions { public static double Map(double sourceMin, double sourceMax, double targetMin, double targetMax, double value) => - ((value) / (sourceMax - sourceMin)) * (targetMax - targetMin); + (value / (sourceMax - sourceMin)) * (targetMax - targetMin); } } diff --git a/src/MudBlazor/Interop/ResizeListenerInterop.cs b/src/MudBlazor/Interop/ResizeListenerInterop.cs index a4e9b18f729f..335063cdb96a 100644 --- a/src/MudBlazor/Interop/ResizeListenerInterop.cs +++ b/src/MudBlazor/Interop/ResizeListenerInterop.cs @@ -22,9 +22,9 @@ public ResizeListenerInterop(IJSRuntime jsRuntime) public async ValueTask MatchMedia(string mediaQuery) { - var matchMedia = await _jsRuntime.InvokeAsyncWithErrorHandling(false, "mudResizeListener.matchMedia", mediaQuery); + var (success, value) = await _jsRuntime.InvokeAsyncWithErrorHandling(false, "mudResizeListener.matchMedia", mediaQuery); - return matchMedia.value; + return value; } public ValueTask ListenForResize<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(DotNetObjectReference dotNetObjectReference, ResizeOptions options, Guid javaScriptListerId) where T : class @@ -49,8 +49,8 @@ public ValueTask Dispose() public async ValueTask GetBrowserWindowSize() { - var size = await _jsRuntime.InvokeAsyncWithErrorHandling(new BrowserWindowSize(), "mudResizeListener.getBrowserWindowSize"); + var (success, value) = await _jsRuntime.InvokeAsyncWithErrorHandling(new BrowserWindowSize(), "mudResizeListener.getBrowserWindowSize"); - return size.value; + return value; } } diff --git a/src/MudBlazor/Services/DialogService.cs b/src/MudBlazor/Services/DialogService.cs index 042c82a7dd69..3c8cabb31dde 100644 --- a/src/MudBlazor/Services/DialogService.cs +++ b/src/MudBlazor/Services/DialogService.cs @@ -190,7 +190,7 @@ public async Task ShowAsync([DynamicallyAccessedMembers(Dynami public Task ShowMessageBox(string title, string message, string yesText = "OK", string noText = null, string cancelText = null, DialogOptions options = null) { - return this.ShowMessageBox(new MessageBoxOptions + return ShowMessageBox(new MessageBoxOptions { Title = title, Message = message, @@ -203,7 +203,7 @@ public async Task ShowAsync([DynamicallyAccessedMembers(Dynami public Task ShowMessageBox(string title, MarkupString markupMessage, string yesText = "OK", string noText = null, string cancelText = null, DialogOptions options = null) { - return this.ShowMessageBox(new MessageBoxOptions + return ShowMessageBox(new MessageBoxOptions { Title = title, MarkupMessage = markupMessage, @@ -224,7 +224,7 @@ public async Task ShowAsync([DynamicallyAccessedMembers(Dynami [nameof(MessageBoxOptions.NoText)] = messageBoxOptions.NoText, [nameof(MessageBoxOptions.YesText)] = messageBoxOptions.YesText, }; - var reference = await ShowAsync(parameters: parameters, options: options, title: messageBoxOptions.Title); + var reference = await ShowAsync(title: messageBoxOptions.Title, parameters: parameters, options: options); var result = await reference.Result; if (result.Canceled || result.Data is not bool data) return null; diff --git a/src/MudBlazor/Services/EventManager/EventManager.cs b/src/MudBlazor/Services/EventManager/EventManager.cs index f9b1ce09339d..8b8ff32337a1 100644 --- a/src/MudBlazor/Services/EventManager/EventManager.cs +++ b/src/MudBlazor/Services/EventManager/EventManager.cs @@ -63,7 +63,7 @@ public interface IEventListener : IAsyncDisposable Task Unsubscribe(Guid key); } - public class EventListener : IEventListener, IAsyncDisposable, IDisposable + public class EventListener : IEventListener, IDisposable { private readonly IJSRuntime _jsRuntime; private readonly DotNetObjectReference _dotNetRef; @@ -83,17 +83,17 @@ public async Task OnEventOccur(Guid key, string @eventData) { if (_callbackResolver.ContainsKey(key) == false) { return; } - var element = _callbackResolver[key]; + var (eventType, callback) = _callbackResolver[key]; - var @event = JsonSerializer.Deserialize(eventData, element.eventType, new WebEventJsonContext(new JsonSerializerOptions + var @event = JsonSerializer.Deserialize(eventData, eventType, new WebEventJsonContext(new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true, })); - if (element.callback != null) + if (callback != null) { - await element.callback.Invoke(@event); + await callback.Invoke(@event); } } @@ -152,7 +152,7 @@ private Guid RegisterCallBack(Type type, Func callback) public async ValueTask DisposeAsync() { - if (_disposed == true) { return; } + if (_disposed) { return; } foreach (var item in _callbackResolver) { diff --git a/src/MudBlazor/Services/IIJSRuntimeExtentions.cs b/src/MudBlazor/Services/IIJSRuntimeExtentions.cs index bd6dd5cbb14c..8b07131bc80a 100644 --- a/src/MudBlazor/Services/IIJSRuntimeExtentions.cs +++ b/src/MudBlazor/Services/IIJSRuntimeExtentions.cs @@ -224,11 +224,11 @@ public static async ValueTask InvokeVoidAsyncWithErrorHandling(this IJSRun /// The JSON-serializable return type. /// The . /// The value that should be returned in case an exception occured + /// An identifier for the function to invoke. For example, the value "someScope.someFunction" will invoke the function window.someScope.someFunction. /// /// A cancellation token to signal the cancellation of the operation. Specifying this parameter will override any default cancellations such as due to timeouts /// () from being applied. /// - /// An identifier for the function to invoke. For example, the value "someScope.someFunction" will invoke the function window.someScope.someFunction. /// JSON-serializable arguments. /// An instance of obtained by JSON-deserializing the return value into a tuple. The first item (sucess) is true in case where there was no exception, otherwise fall. public static async ValueTask<(bool success, TValue value)> InvokeAsyncWithErrorHandling<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.PublicProperties)] TValue>(this IJSRuntime jsRuntime, TValue fallbackValue, string identifier, CancellationToken cancellationToken, params object[] args) diff --git a/src/MudBlazor/Services/JsEvent/JsEventOptions.cs b/src/MudBlazor/Services/JsEvent/JsEventOptions.cs index 160977984d20..8f96fbf12cb7 100644 --- a/src/MudBlazor/Services/JsEvent/JsEventOptions.cs +++ b/src/MudBlazor/Services/JsEvent/JsEventOptions.cs @@ -9,9 +9,8 @@ namespace MudBlazor.Services public class JsEventOptions { /// - /// Class of the target node which should be observed for keyboard events - /// - /// Note: this must be a single class + /// Class of the target node which should be observed for keyboard events + /// Note: this must be a single class /// public string TargetClass { get; set; } diff --git a/src/MudBlazor/Services/KeyInterceptor/KeyInterceptor.cs b/src/MudBlazor/Services/KeyInterceptor/KeyInterceptor.cs index 4f4e023e0ab2..43d0935c2506 100644 --- a/src/MudBlazor/Services/KeyInterceptor/KeyInterceptor.cs +++ b/src/MudBlazor/Services/KeyInterceptor/KeyInterceptor.cs @@ -20,7 +20,7 @@ namespace MudBlazor.Services /// It can call preventDefault or stopPropagation directly on the JavaScript side for single key strokes / key combinations as per configuration. /// Furthermore, you can precisely subscribe single keystrokes or combinations and only the subscribed ones will be forwarded into .NET /// - public class KeyInterceptor : IKeyInterceptor, IDisposable + public class KeyInterceptor : IKeyInterceptor { private bool _isDisposed = false; diff --git a/src/MudBlazor/Services/KeyInterceptor/KeyInterceptorOptions.cs b/src/MudBlazor/Services/KeyInterceptor/KeyInterceptorOptions.cs index f706a4a7fd19..22b5af040b1c 100644 --- a/src/MudBlazor/Services/KeyInterceptor/KeyInterceptorOptions.cs +++ b/src/MudBlazor/Services/KeyInterceptor/KeyInterceptorOptions.cs @@ -9,9 +9,8 @@ namespace MudBlazor.Services public class KeyInterceptorOptions { /// - /// Class of the target node which should be observed for keyboard events - /// - /// Note: this must be a single class + /// Class of the target node which should be observed for keyboard events + /// Note: this must be a single class /// public string TargetClass { get; set; } @@ -27,15 +26,17 @@ public class KeyInterceptorOptions } /// - /// Configuration for preventDefault() and stopPropagation() control - /// + /// Configuration for preventDefault() and stopPropagation() control + /// /// For PreventDown, PreventUp, StopDown and StopUp the configuration which key combinations should match /// is a Javascript boolean expression. - /// + /// + /// /// Examples: /// For the examples, let's assume the Tab key was pressed. /// Note: for combinations of more than one modifier the following order of modifiers must be followed strictly: shift+ctrl+alt+meta - /// + /// + /// /// * Don't prevent key down: /// PreventDown=null or PreventDown="none" /// * Prevent key down of unmodified keystrokes such as "Tab": @@ -52,15 +53,17 @@ public class KeyInterceptorOptions /// PreventDown="key+any" /// * Prevent any combination of key and modifiers, even the unmodified key: /// PreventDown="any" + /// /// public class KeyOptions { /// - /// Javascript keyboard event.key - /// + /// Javascript keyboard event.key + /// /// Examples: " " for space, "Tab" for tab, "a" for lowercase A-key. /// Also allowed: JS regex such as "/[a-z]/" or "/a|b/" but NOT "/[a-z]/g" or "/[a-z]/i" /// regex must be enclosed in two forward slashes! + /// /// public string Key { get; set; } diff --git a/src/MudBlazor/Services/Localization/MudLocalizer.cs b/src/MudBlazor/Services/Localization/MudLocalizer.cs index b5e7e8ce9e3f..be970e50e9a9 100644 --- a/src/MudBlazor/Services/Localization/MudLocalizer.cs +++ b/src/MudBlazor/Services/Localization/MudLocalizer.cs @@ -6,9 +6,9 @@ namespace MudBlazor; /// /// This customizable localizer service allows users to supply custom translations for MudBlazor components. /// Users can register custom implementations using the following syntax, where the scope depends on the implementation: -/// services.Add{scope}Transient<MudLocalizer, CustomMudLocalizerImpl>() +/// services.Add{scope}Transient<MudLocalizer, CustomMudLocalizerImpl>() /// or -/// services.TryAdd{scope}Transient<MudLocalizer, CustomMudLocalizerImpl>() +/// services.TryAdd{scope}Transient<MudLocalizer, CustomMudLocalizerImpl>() /// public class MudLocalizer { diff --git a/src/MudBlazor/Services/ResizeObserver/ResizeObserver.cs b/src/MudBlazor/Services/ResizeObserver/ResizeObserver.cs index aa7521bf3778..f5afb0bdd453 100644 --- a/src/MudBlazor/Services/ResizeObserver/ResizeObserver.cs +++ b/src/MudBlazor/Services/ResizeObserver/ResizeObserver.cs @@ -10,7 +10,7 @@ namespace MudBlazor.Services { - public class ResizeObserver : IResizeObserver, IDisposable, IAsyncDisposable + public class ResizeObserver : IResizeObserver, IAsyncDisposable { private bool _isDisposed = false; @@ -131,7 +131,7 @@ public void Dispose() public async ValueTask DisposeAsync() { - if (_isDisposed == true) { return; } + if (_isDisposed) { return; } _isDisposed = true; diff --git a/src/MudBlazor/Services/Scroll/ScrollListener.cs b/src/MudBlazor/Services/Scroll/ScrollListener.cs index ad2bb3bc9f93..e2c162c33c82 100644 --- a/src/MudBlazor/Services/Scroll/ScrollListener.cs +++ b/src/MudBlazor/Services/Scroll/ScrollListener.cs @@ -18,7 +18,7 @@ public interface IScrollListener : IDisposable event EventHandler OnScroll; } - internal class ScrollListener : IScrollListener, IDisposable + internal class ScrollListener : IScrollListener { private readonly IJSRuntime _js; private DotNetObjectReference _dotNetRef; diff --git a/src/MudBlazor/Services/Scroll/ScrollManagerException.cs b/src/MudBlazor/Services/Scroll/ScrollManagerException.cs index 56b947d28c05..0392bbcaf732 100644 --- a/src/MudBlazor/Services/Scroll/ScrollManagerException.cs +++ b/src/MudBlazor/Services/Scroll/ScrollManagerException.cs @@ -7,7 +7,7 @@ namespace MudBlazor [ExcludeFromCodeCoverage] public class ScrollManagerException : Exception { - public ScrollManagerException() : base() { } + public ScrollManagerException() { } public ScrollManagerException(string message) : base(message) { } public ScrollManagerException(string message, Exception inner) : base(message, inner) { } } diff --git a/src/MudBlazor/Utilities/BindingConverters/Converter.cs b/src/MudBlazor/Utilities/BindingConverters/Converter.cs index 1b1d81ba81a5..d4c8cdffd60a 100644 --- a/src/MudBlazor/Utilities/BindingConverters/Converter.cs +++ b/src/MudBlazor/Utilities/BindingConverters/Converter.cs @@ -80,10 +80,11 @@ protected void UpdateGetError(string msg) } /// - /// Converter from T to string - /// + /// Converter from T to string + /// /// Set converts to string /// Get converts from string + /// /// public class Converter : Converter { diff --git a/src/MudBlazor/Utilities/BindingConverters/NumericConverter.cs b/src/MudBlazor/Utilities/BindingConverters/NumericConverter.cs index 8b3eb469d899..4b5dea6cdca6 100644 --- a/src/MudBlazor/Utilities/BindingConverters/NumericConverter.cs +++ b/src/MudBlazor/Utilities/BindingConverters/NumericConverter.cs @@ -6,10 +6,11 @@ namespace MudBlazor { /// - /// A universal T to double binding converter - /// + /// A universal T to double binding converter + /// /// Note: currently not in use. Should we ever use it, remove /// the [ExcludeFromCodeCoverage] attribute + /// /// [ExcludeFromCodeCoverage] public class NumericConverter : Converter diff --git a/src/MudBlazor/Utilities/CssBuilder.cs b/src/MudBlazor/Utilities/CssBuilder.cs index 78f57702ac1c..109bcd9786b2 100644 --- a/src/MudBlazor/Utilities/CssBuilder.cs +++ b/src/MudBlazor/Utilities/CssBuilder.cs @@ -55,7 +55,7 @@ public CssBuilder AddValue(string value) /// CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(string value, bool when = true) => when ? this.AddClass(value) : this; + public CssBuilder AddClass(string value, bool when = true) => when ? AddClass(value) : this; /// /// Adds a conditional CSS Class to the builder with space separator. @@ -63,7 +63,7 @@ public CssBuilder AddValue(string value) /// CSS Class to conditionally add. /// Nullable condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(string value, bool? when = true) => when == true ? this.AddClass(value) : this; + public CssBuilder AddClass(string value, bool? when = true) => when == true ? AddClass(value) : this; /// /// Adds a conditional CSS Class to the builder with space separator. @@ -71,7 +71,7 @@ public CssBuilder AddValue(string value) /// CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(string value, Func when = null) => this.AddClass(value, when != null && when()); + public CssBuilder AddClass(string value, Func when = null) => AddClass(value, when != null && when()); /// /// Adds a conditional CSS Class to the builder with space separator. @@ -79,7 +79,7 @@ public CssBuilder AddValue(string value) /// Function that returns a CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(Func value, bool when = true) => when ? this.AddClass(value()) : this; + public CssBuilder AddClass(Func value, bool when = true) => when ? AddClass(value()) : this; /// /// Adds a conditional CSS Class to the builder with space separator. @@ -87,7 +87,7 @@ public CssBuilder AddValue(string value) /// Function that returns a CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(Func value, Func when = null) => this.AddClass(value, when != null && when()); + public CssBuilder AddClass(Func value, Func when = null) => AddClass(value, when != null && when()); /// /// Adds a conditional nested CssBuilder to the builder with space separator. @@ -95,7 +95,7 @@ public CssBuilder AddValue(string value) /// CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(CssBuilder builder, bool when = true) => when ? this.AddClass(builder.Build()) : this; + public CssBuilder AddClass(CssBuilder builder, bool when = true) => when ? AddClass(builder.Build()) : this; /// /// Adds a conditional CSS Class to the builder with space separator. @@ -103,7 +103,7 @@ public CssBuilder AddValue(string value) /// CSS Class to conditionally add. /// Condition in which the CSS Class is added. /// CssBuilder - public CssBuilder AddClass(CssBuilder builder, Func when = null) => this.AddClass(builder, when != null && when()); + public CssBuilder AddClass(CssBuilder builder, Func when = null) => AddClass(builder, when != null && when()); /// /// Adds a conditional CSS Class when it exists in a dictionary to the builder with space separator. diff --git a/src/MudBlazor/Utilities/MaskAlgorithms/BaseMask.cs b/src/MudBlazor/Utilities/MaskAlgorithms/BaseMask.cs index 266ee93dc33f..561334981329 100644 --- a/src/MudBlazor/Utilities/MaskAlgorithms/BaseMask.cs +++ b/src/MudBlazor/Utilities/MaskAlgorithms/BaseMask.cs @@ -152,8 +152,7 @@ protected virtual bool IsDelimiter(char maskChar) public virtual void UpdateFrom(IMask o) { - var other = o as BaseMask; - if (other == null) + if (o is not BaseMask other) return; if (other.Mask != Mask) { diff --git a/src/MudBlazor/Utilities/MaskAlgorithms/DateMask.cs b/src/MudBlazor/Utilities/MaskAlgorithms/DateMask.cs index 8c052166f1f3..42fc37fa69b9 100644 --- a/src/MudBlazor/Utilities/MaskAlgorithms/DateMask.cs +++ b/src/MudBlazor/Utilities/MaskAlgorithms/DateMask.cs @@ -221,8 +221,7 @@ private int GetDaysInMonth(int year, int month) public override void UpdateFrom(IMask other) { base.UpdateFrom(other); - var o = other as DateMask; - if (o == null) + if (other is not DateMask o) return; _y = o._y; _M = o._M; diff --git a/src/MudBlazor/Utilities/MaskAlgorithms/MultiMask.cs b/src/MudBlazor/Utilities/MaskAlgorithms/MultiMask.cs index f455a6d0ca73..24b064ceb3a2 100644 --- a/src/MudBlazor/Utilities/MaskAlgorithms/MultiMask.cs +++ b/src/MudBlazor/Utilities/MaskAlgorithms/MultiMask.cs @@ -87,8 +87,7 @@ protected void DoCheckAndRedo(Action action) public override void UpdateFrom(IMask other) { base.UpdateFrom(other); - var o = other as MultiMask; - if (o == null) + if (other is not MultiMask o) return; // no need to re-initialize, just update the options _defaultMask = o._defaultMask; diff --git a/src/MudBlazor/Utilities/MaskAlgorithms/PatternMask.cs b/src/MudBlazor/Utilities/MaskAlgorithms/PatternMask.cs index 35386bb7c71b..b5f2e4dd7cd8 100644 --- a/src/MudBlazor/Utilities/MaskAlgorithms/PatternMask.cs +++ b/src/MudBlazor/Utilities/MaskAlgorithms/PatternMask.cs @@ -183,7 +183,7 @@ protected virtual string AlignAgainstMask(string text, int maskOffset = 0) ModifyPartiallyAlignedMask(mask, text, maskOffset, ref textIndex, ref maskIndex, ref alignedText); } // fill any delimiters if possible - for (int i = maskIndex; i < mask.Length; i++) + for (var i = maskIndex; i < mask.Length; i++) { var maskChar = mask[i]; if (!IsDelimiter(maskChar)) @@ -257,8 +257,7 @@ protected virtual string ModifyFinalText(string text) public override void UpdateFrom(IMask other) { base.UpdateFrom(other); - var o = other as PatternMask; - if (o == null) + if (other is not PatternMask o) return; Placeholder = o.Placeholder; CleanDelimiters = o.CleanDelimiters; diff --git a/src/MudBlazor/Utilities/MaskAlgorithms/RegexMask.cs b/src/MudBlazor/Utilities/MaskAlgorithms/RegexMask.cs index f6d4c3a449d4..e06aa5a872ed 100644 --- a/src/MudBlazor/Utilities/MaskAlgorithms/RegexMask.cs +++ b/src/MudBlazor/Utilities/MaskAlgorithms/RegexMask.cs @@ -179,8 +179,7 @@ protected virtual string AlignAgainstMask(string text) public override void UpdateFrom(IMask other) { base.UpdateFrom(other); - var o = other as RegexMask; - if (o == null) + if (other is not RegexMask o) return; if (Delimiters != o.Delimiters) { diff --git a/src/MudBlazor/Utilities/MudColor.cs b/src/MudBlazor/Utilities/MudColor.cs index 46018f4074ca..5c9a341c0230 100644 --- a/src/MudBlazor/Utilities/MudColor.cs +++ b/src/MudBlazor/Utilities/MudColor.cs @@ -46,7 +46,7 @@ public class MudColor : IEquatable public byte G => _valuesAsByte[1]; public byte B => _valuesAsByte[2]; public byte A => _valuesAsByte[3]; - public double APercentage => Math.Round((A / 255.0), 2); + public double APercentage => Math.Round(A / 255.0, 2); public double H { get; private set; } public double L { get; private set; } @@ -161,7 +161,7 @@ public MudColor(string value) { value = value.Trim().ToLower(); - if (value.StartsWith("rgba") == true) + if (value.StartsWith("rgba")) { var parts = SplitInputIntoParts(value); if (parts.Length != 4) @@ -177,7 +177,7 @@ public MudColor(string value) (byte)Math.Max(0, Math.Min(255, 255 * double.Parse(parts[3],CultureInfo.InvariantCulture))), }; } - else if (value.StartsWith("rgb") == true) + else if (value.StartsWith("rgb")) { var parts = SplitInputIntoParts(value); if (parts.Length != 3) @@ -316,7 +316,7 @@ private static string[] SplitInputIntoParts(string value) private byte GetByteFromValuePart(string input, int index) => byte.Parse(new string(new char[] { input[index], input[index + 1] }), NumberStyles.HexNumber); - public bool HslChanged(MudColor value) => this.H != value.H || this.S != value.S || this.L != value.L; + public bool HslChanged(MudColor value) => H != value.H || S != value.S || L != value.L; #endregion @@ -343,7 +343,7 @@ private static string[] SplitInputIntoParts(string value) public bool Equals(MudColor other) { - if (ReferenceEquals(other, null) == true) { return false; } + if (ReferenceEquals(other, null)) { return false; } return _valuesAsByte[0] == other._valuesAsByte[0] && @@ -358,13 +358,13 @@ public bool Equals(MudColor other) { var lhsIsNull = ReferenceEquals(null, lhs); var rhsIsNull = ReferenceEquals(null, rhs); - if (lhsIsNull == true && rhsIsNull == true) + if (lhsIsNull && rhsIsNull) { return true; } else { - if ((lhsIsNull || rhsIsNull) == true) + if ((lhsIsNull || rhsIsNull)) { return false; } diff --git a/src/MudBlazor/Utilities/NaturalComparer.cs b/src/MudBlazor/Utilities/NaturalComparer.cs index c3a9bb5acb17..3725040f61c1 100644 --- a/src/MudBlazor/Utilities/NaturalComparer.cs +++ b/src/MudBlazor/Utilities/NaturalComparer.cs @@ -55,33 +55,33 @@ public static int CompareNatural(string strA, string strB) public static int CompareNatural(string strA, string strB, CultureInfo culture, CompareOptions options) { - CompareInfo cmp = culture.CompareInfo; - int iA = 0; - int iB = 0; - int softResult = 0; - int softResultWeight = 0; + var cmp = culture.CompareInfo; + var iA = 0; + var iB = 0; + var softResult = 0; + var softResultWeight = 0; while (iA < strA.Length && iB < strB.Length) { - bool isDigitA = char.IsDigit(strA[iA]); - bool isDigitB = char.IsDigit(strB[iB]); + var isDigitA = char.IsDigit(strA[iA]); + var isDigitB = char.IsDigit(strB[iB]); if (isDigitA != isDigitB) { return cmp.Compare(strA, iA, strB, iB, options); } else if (!isDigitA && !isDigitB) { - int jA = iA + 1; - int jB = iB + 1; + var jA = iA + 1; + var jB = iB + 1; while (jA < strA.Length && !char.IsDigit(strA[jA])) jA++; while (jB < strB.Length && !char.IsDigit(strB[jB])) jB++; - int cmpResult = cmp.Compare(strA, iA, jA - iA, strB, iB, jB - iB, options); + var cmpResult = cmp.Compare(strA, iA, jA - iA, strB, iB, jB - iB, options); if (cmpResult != 0) { // Certain strings may be considered different due to "soft" differences that are // ignored if more significant differences follow, e.g. a hyphen only affects the // comparison if no other differences follow - string sectionA = strA.Substring(iA, jA - iA); - string sectionB = strB.Substring(iB, jB - iB); + var sectionA = strA.Substring(iA, jA - iA); + var sectionB = strB.Substring(iB, jB - iB); if (cmp.Compare(sectionA + "1", sectionB + "2", options) == cmp.Compare(sectionA + "2", sectionB + "1", options)) { @@ -98,19 +98,19 @@ public static int CompareNatural(string strA, string strB, CultureInfo culture, } else { - char zeroA = (char)(strA[iA] - (int)char.GetNumericValue(strA[iA])); - char zeroB = (char)(strB[iB] - (int)char.GetNumericValue(strB[iB])); - int jA = iA; - int jB = iB; + var zeroA = (char)(strA[iA] - (int)char.GetNumericValue(strA[iA])); + var zeroB = (char)(strB[iB] - (int)char.GetNumericValue(strB[iB])); + var jA = iA; + var jB = iB; while (jA < strA.Length && strA[jA] == zeroA) jA++; while (jB < strB.Length && strB[jB] == zeroB) jB++; - int resultIfSameLength = 0; + var resultIfSameLength = 0; do { isDigitA = jA < strA.Length && char.IsDigit(strA[jA]); isDigitB = jB < strB.Length && char.IsDigit(strB[jB]); - int numA = isDigitA ? (int)char.GetNumericValue(strA[jA]) : 0; - int numB = isDigitB ? (int)char.GetNumericValue(strB[jB]) : 0; + var numA = isDigitA ? (int)char.GetNumericValue(strA[jA]) : 0; + var numB = isDigitB ? (int)char.GetNumericValue(strB[jB]) : 0; if (isDigitA && (char)(strA[jA] - numA) != zeroA) isDigitA = false; if (isDigitB && (char)(strB[jB] - numB) != zeroB) isDigitB = false; if (isDigitA && isDigitB) @@ -136,8 +136,8 @@ public static int CompareNatural(string strA, string strB, CultureInfo culture, // the digits differed - the first difference determines the result return resultIfSameLength; } - int lA = jA - iA; - int lB = jB - iB; + var lA = jA - iA; + var lB = jB - iB; if (lA != lB) { // Both numbers are equivalent but one has more leading zeros diff --git a/src/MudBlazor/Utilities/SortingAssistent.cs b/src/MudBlazor/Utilities/SortingAssistent.cs index 8163ac844b46..f67919f38988 100644 --- a/src/MudBlazor/Utilities/SortingAssistent.cs +++ b/src/MudBlazor/Utilities/SortingAssistent.cs @@ -16,8 +16,7 @@ public static class SortingAssistent { public static void UpdateOrder(this IEnumerable items, MudItemDropInfo dropInfo, Expression> valueUpdater, int zoneOffset = 0) { - var memberSelectorExpression = valueUpdater.Body as MemberExpression; - if (memberSelectorExpression == null) { throw new InvalidOperationException(); } + if (valueUpdater.Body is not MemberExpression memberSelectorExpression) { throw new InvalidOperationException(); } var property = memberSelectorExpression.Member as PropertyInfo; @@ -27,10 +26,10 @@ public static void UpdateOrder(this IEnumerable items, MudItemDropInfo var item = dropInfo.Item; - int index = 0; + var index = 0; foreach (var _item in items.OrderBy(x => (int)property.GetValue(x))) { - if (_item.Equals(item) == true) + if (_item.Equals(item)) { property.SetValue(item, newIndex); } diff --git a/src/MudBlazor/Utilities/StyleBuilder.cs b/src/MudBlazor/Utilities/StyleBuilder.cs index 50d76a7fd8a8..6c35919313d4 100644 --- a/src/MudBlazor/Utilities/StyleBuilder.cs +++ b/src/MudBlazor/Utilities/StyleBuilder.cs @@ -68,7 +68,7 @@ private StyleBuilder AddRaw(string style) /// Style to conditionally add. /// Condition in which the style is added. /// StyleBuilder - public StyleBuilder AddStyle(string prop, string value, bool when = true) => when ? this.AddStyle(prop, value) : this; + public StyleBuilder AddStyle(string prop, string value, bool when = true) => when ? AddStyle(prop, value) : this; /// @@ -78,7 +78,7 @@ private StyleBuilder AddRaw(string style) /// Style to conditionally add. /// Condition in which the style is added. /// - public StyleBuilder AddStyle(string prop, Func value, bool when = true) => when ? this.AddStyle(prop, value()) : this; + public StyleBuilder AddStyle(string prop, Func value, bool when = true) => when ? AddStyle(prop, value()) : this; /// /// Adds a conditional in-line style to the builder with space separator and closing semicolon.. @@ -87,7 +87,7 @@ private StyleBuilder AddRaw(string style) /// Style to conditionally add. /// Condition in which the style is added. /// StyleBuilder - public StyleBuilder AddStyle(string prop, string value, Func when = null) => this.AddStyle(prop, value, when != null && when()); + public StyleBuilder AddStyle(string prop, string value, Func when = null) => AddStyle(prop, value, when != null && when()); /// /// Adds a conditional in-line style to the builder with space separator and closing semicolon.. @@ -96,14 +96,14 @@ private StyleBuilder AddRaw(string style) /// Style to conditionally add. /// Condition in which the style is added. /// StyleBuilder - public StyleBuilder AddStyle(string prop, Func value, Func when = null) => this.AddStyle(prop, value(), when != null && when()); + public StyleBuilder AddStyle(string prop, Func value, Func when = null) => AddStyle(prop, value(), when != null && when()); /// /// Adds a conditional nested StyleBuilder to the builder with separator and closing semicolon. /// /// Style Builder to conditionally add. /// StyleBuilder - public StyleBuilder AddStyle(StyleBuilder builder) => this.AddRaw(builder.Build()); + public StyleBuilder AddStyle(StyleBuilder builder) => AddRaw(builder.Build()); /// /// Adds a conditional nested StyleBuilder to the builder with separator and closing semicolon. @@ -111,7 +111,7 @@ private StyleBuilder AddRaw(string style) /// Style Builder to conditionally add. /// Condition in which the style is added. /// StyleBuilder - public StyleBuilder AddStyle(StyleBuilder builder, bool when = true) => when ? this.AddRaw(builder.Build()) : this; + public StyleBuilder AddStyle(StyleBuilder builder, bool when = true) => when ? AddRaw(builder.Build()) : this; /// /// Adds a conditional in-line style to the builder with space separator and closing semicolon.. @@ -119,7 +119,7 @@ private StyleBuilder AddRaw(string style) /// Style Builder to conditionally add. /// Condition in which the styles are added. /// StyleBuilder - public StyleBuilder AddStyle(StyleBuilder builder, Func when = null) => this.AddStyle(builder, when != null && when()); + public StyleBuilder AddStyle(StyleBuilder builder, Func when = null) => AddStyle(builder, when != null && when()); /// /// Adds a conditional in-line style to the builder with space separator and closing semicolon..