diff --git a/.gitattributes b/.gitattributes index 176a458f..883fcc0a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,5 @@ * text=auto + +# Enforce Windows newlines for C# files to avoid false positives with IDE0055 warning. +# See https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions/issues/106 for more information. +*.cs text eol=crlf diff --git a/Extensions/Widgets/Constants/RouteValueNames.cs b/Extensions/Widgets/Constants/RouteValueNames.cs index df883714..976c508a 100644 --- a/Extensions/Widgets/Constants/RouteValueNames.cs +++ b/Extensions/Widgets/Constants/RouteValueNames.cs @@ -1,7 +1,7 @@ -namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Constants; - -public static class RouteValueNames -{ - private const string MenuWidgetRoot = "Lombiq.MenuWidget."; - public const string MenuWidgetPost = MenuWidgetRoot + "Post"; -} +namespace Lombiq.HelpfulExtensions.Extensions.Widgets.Constants; + +public static class RouteValueNames +{ + private const string MenuWidgetRoot = "Lombiq.MenuWidget."; + public const string MenuWidgetPost = MenuWidgetRoot + "Post"; +} diff --git a/Views/MenuWidget.cshtml b/Views/MenuWidget.cshtml index ff4a707b..93e68154 100644 --- a/Views/MenuWidget.cshtml +++ b/Views/MenuWidget.cshtml @@ -1,139 +1,139 @@ -@using Lombiq.HelpfulExtensions.Extensions.Widgets.ViewModels -@using Microsoft.AspNetCore.Http.Extensions -@using OrchardCore.Navigation - - -@{ - var viewModel = new MenuWidgetViewModel(Model); - - const string blockName = "menuWidget"; - const string contentElementName = blockName + "__content"; - const string togglerElementName = blockName + "__toggler"; - const string dropdownElementName = blockName + "__dropdown"; - const string dropdownItemElementName = blockName + "__dropdownItem"; - - var contentIdName = FormattableString.Invariant($"{contentElementName}_{Guid.NewGuid()}"); - - var baseUri = new Uri(Context.Request.GetDisplayUrl()); - - var menuItems = viewModel - .MenuItems - .OrderBy(item => double.TryParse(item.Position, out var number) ? number : double.MaxValue) - .ThenBy(item => item.Position); - - // We use LocalizedString.Name instead of Value intentionally, as this shouldn't be affected by localization. - bool IsDivider(MenuItem menuItem) => - menuItem.Text.Name.Length >= 3 && menuItem.Text.Name.All(character => character == '-'); - - bool IsFormPost(Uri uri) => uri - .Query - .TrimStart('?') - .Split('&') - .Contains("Lombiq.MenuWidget.Post=true", StringComparer.OrdinalIgnoreCase); -} - -@if (!viewModel.NoWrapper) -{ - @: -} +@using Lombiq.HelpfulExtensions.Extensions.Widgets.ViewModels +@using Microsoft.AspNetCore.Http.Extensions +@using OrchardCore.Navigation + + +@{ + var viewModel = new MenuWidgetViewModel(Model); + + const string blockName = "menuWidget"; + const string contentElementName = blockName + "__content"; + const string togglerElementName = blockName + "__toggler"; + const string dropdownElementName = blockName + "__dropdown"; + const string dropdownItemElementName = blockName + "__dropdownItem"; + + var contentIdName = FormattableString.Invariant($"{contentElementName}_{Guid.NewGuid()}"); + + var baseUri = new Uri(Context.Request.GetDisplayUrl()); + + var menuItems = viewModel + .MenuItems + .OrderBy(item => double.TryParse(item.Position, out var number) ? number : double.MaxValue) + .ThenBy(item => item.Position); + + // We use LocalizedString.Name instead of Value intentionally, as this shouldn't be affected by localization. + bool IsDivider(MenuItem menuItem) => + menuItem.Text.Name.Length >= 3 && menuItem.Text.Name.All(character => character == '-'); + + bool IsFormPost(Uri uri) => uri + .Query + .TrimStart('?') + .Split('&') + .Contains("Lombiq.MenuWidget.Post=true", StringComparer.OrdinalIgnoreCase); +} + +@if (!viewModel.NoWrapper) +{ + @: +}