From 30854b3729da2ac6b790951149710c78cdf7cd81 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 6 Apr 2024 19:27:09 +0300 Subject: [PATCH 1/2] Add missing string comparison type * Use System.StringComparison.Ordinal by default * Fix minor other issues or disable with pragma * Configure inspection level and allow list in Directory.Build.props --- Directory.Build.props | 54 +++++++++++++++++++ .../Handlers/AliasPartHandler.cs | 2 +- .../Handlers/AutoroutePartHandler.cs | 4 +- .../GraphQL/Types/HtmlFieldQueryObjectType.cs | 4 +- .../LocalizedContentItemsQueryProvider.cs | 8 +-- .../Handlers/PreviewPartHandler.cs | 2 +- .../AuditTrailPartSettingsDisplayDriver.cs | 10 +++- .../Controllers/AdminController.cs | 2 +- .../ContentTypesSitemapSourceBuilder.cs | 4 +- .../ContentTypesSitemapSourceDriver.cs | 12 ++--- ...tTypesSitemapSourceModifiedDateProvider.cs | 2 +- .../ContentTypesSitemapSourceUpdateHandler.cs | 4 +- .../DefaultContentItemsQueryProvider.cs | 4 +- .../Services/SmtpService.cs | 2 +- .../Migrations/EmailMigrations.cs | 2 + .../FacebookLoginConfiguration.cs | 2 +- .../FacebookPluginPartDisplayDriver.cs | 2 +- .../GithubOptionsConfiguration.cs | 2 +- .../GoogleOptionsConfiguration.cs | 2 +- .../GraphQL/HtmlBodyQueryObjectType.cs | 2 +- .../Handlers/HtmlBodyPartHandler.cs | 2 +- .../Controllers/AdminController.cs | 6 +-- .../Controllers/LayerRuleController.cs | 12 ++--- .../Handlers/ContainedPartHandler.cs | 2 +- .../RemotePublishing/MetaWeblogHandler.cs | 2 +- .../GraphQL/MarkdownBodyQueryObjectType.cs | 2 +- .../GraphQL/MarkdownFieldQueryObjectType.cs | 4 +- .../Handlers/MarkdownBodyPartHandler.cs | 2 +- .../ManageMediaFolderAuthorizationHandler.cs | 2 +- .../AzureADOptionsConfiguration.cs | 4 +- .../MicrosoftAccountOptionsConfiguration.cs | 2 +- .../OpenIdClientConfiguration.cs | 2 +- .../OpenIdValidationConfiguration.cs | 6 +-- .../Controllers/AccessController.cs | 2 +- .../Controllers/ScopeController.cs | 12 ++--- .../Controllers/UserInfoController.cs | 2 +- .../Services/OpenIdValidationService.cs | 2 +- .../OrchardCore.Roles/Services/RoleStore.cs | 4 +- .../ViewModels/PermissionGroupKey.cs | 2 +- .../Services/StringOperatorComparer.cs | 4 +- ...tPickerFieldElasticEditorSettingsDriver.cs | 2 +- ...ntPickerFieldLuceneEditorSettingsDriver.cs | 2 +- .../Providers/LocaleShortcodeProvider.cs | 4 +- .../Handlers/SitemapIndexTypeUpdateHandler.cs | 4 +- .../Handlers/TitlePartHandler.cs | 2 +- .../Services/TwitterClientMessageHandler.cs | 2 + .../TwitterOptionsConfiguration.cs | 2 +- .../Controllers/AuthenticatorAppController.cs | 2 + .../OrchardCore.Widgets/ContentCardShapes.cs | 4 +- .../Services/LocalizedStringComparer.cs | 2 +- .../ContentFieldDisplayDriver.cs | 12 ++--- .../ServiceCollectionExtensions.cs | 6 +-- ...ContentPartFieldDefinitionDisplayDriver.cs | 2 +- .../ContentTypePartDefinitionDisplayDriver.cs | 2 +- .../ShapePlacementParsingStrategy.cs | 2 +- .../Shapes/AlternatesCollection.cs | 2 +- .../Zones/FlatPositionComparer.cs | 4 +- .../ContentFieldIndexHandler.cs | 4 +- .../Services/MediaSizeLimitAttribute.cs | 4 +- .../ModuleProjectRazorFileProvider.cs | 2 +- .../ResourceDefinition.cs | 6 +-- .../ResourceDictionary.cs | 2 + .../AzureAISearchIndexDocumentManager.cs | 4 +- .../ElasticContentPickerResultProvider.cs | 2 +- .../Extensions/Features/FeatureHash.cs | 2 +- .../Modules/ModularBackgroundService.cs | 2 +- .../LifetimeTrackingHttpMessageHandler.cs | 2 + .../HttpClient/TenantHttpClientFactory.cs | 8 +-- .../Modules/Manifest/ModuleAttributeTests.cs | 4 +- .../Apis/Context/AuthenticationContext.cs | 2 +- .../Apis/Context/SiteContext.cs | 2 + .../Apis/GraphQL/Blog/BlogPostTests.cs | 2 +- .../Queries/RecentBlogPostsQueryTests.cs | 2 +- .../OrchardCore.Media/MediaEventTests.cs | 2 + .../OrchardCore.Media/MediaTokenTests.cs | 2 +- .../SubResourceIntegrityTests.cs | 4 +- ...eadersApplicationBuilderExtensionsTests.cs | 2 +- .../OrchardCore.Tenants/ApiControllerTests.cs | 2 +- .../CacheScopeManagerTests.cs | 2 +- .../Shell/ShellContainerFactoryTests.cs | 2 +- .../Stubs/StubPoFileLocationProvider.cs | 2 +- .../Workflows/WorkflowManagerTests.cs | 4 +- 82 files changed, 202 insertions(+), 128 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 4e66696c98d..235d562dc61 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,4 +5,58 @@ true + + + latest-Recommended + + + $(NoWarn);CA1805 + + + $(NoWarn);CA1304;CA1305;CA1310 + + + $(NoWarn);CA1311 + + + $(NoWarn);CA1000 + + + $(NoWarn);CA1848 + + + $(NoWarn);CA1720 + + + $(NoWarn);CA1051 + + + $(NoWarn);CA1200 + + + $(NoWarn);CA1711 + + + $(NoWarn);CA1725 + + + $(NoWarn);CA1716 + + + $(NoWarn);CA1001 + + + $(NoWarn);CA2201 + + + $(NoWarn);CA1707 + + + $(NoWarn);CA1727 + + + $(NoWarn);CA1861 + + + diff --git a/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs index 49fa883d1ff..d3e5ca053b2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs @@ -124,7 +124,7 @@ public override async Task CloningAsync(CloneContentContext context, AliasPart p private async Task GetPatternAsync(AliasPart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AliasPart))); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AliasPart), System.StringComparison.Ordinal)); var pattern = contentTypePartDefinition.GetSettings().Pattern; return pattern; diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutoroutePartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutoroutePartHandler.cs index d8690e060be..554b5f8b654 100644 --- a/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutoroutePartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutoroutePartHandler.cs @@ -157,7 +157,7 @@ public override Task GetContentItemAspectAsync(ContentItemAspectContext context, return context.ForAsync(async aspect => { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "AutoroutePart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "AutoroutePart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); if (settings.ManageContainedItemRoutes) { @@ -425,7 +425,7 @@ private async Task GenerateContainerPathFromPatternAsync(AutoroutePart part) private async Task GetPatternAsync(AutoroutePart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AutoroutePart))); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AutoroutePart), StringComparison.Ordinal)); var pattern = contentTypePartDefinition.GetSettings().Pattern; return pattern; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs index a0146cdf6c0..395b3128e87 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs @@ -45,8 +45,8 @@ private static async ValueTask RenderHtml(IResolveFieldContext string.Equals(x.Name, partName)); - var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName)); + var contentPartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.Name, partName, System.StringComparison.Ordinal)); + var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, System.StringComparison.Ordinal)); var settings = contentPartFieldDefinition.GetSettings(); var html = ctx.Source.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs index 4b7f66dd08a..7645c7cf811 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs @@ -54,14 +54,14 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content type is still valid to include in sitemap. var contentType = routeableContentTypeDefinitions - .FirstOrDefault(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name)); + .FirstOrDefault(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); if (contentType == null) { return; } - if (contentType.Parts.Any(ctd => string.Equals(ctd.Name, nameof(LocalizationPart)))) + if (contentType.Parts.Any(ctd => string.Equals(ctd.Name, nameof(LocalizationPart), System.StringComparison.Ordinal))) { // Get all content items here for reference. Then reduce by default culture. // We know that the content item should be localized. @@ -77,7 +77,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content // Reduce by default culture. var items = queryResults - .Where(ci => string.Equals(ci.As().Culture, defaultCulture)) + .Where(ci => string.Equals(ci.As().Culture, defaultCulture, System.StringComparison.Ordinal)) .Skip(source.LimitedContentType.Skip) .Take(source.LimitedContentType.Take); @@ -104,7 +104,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content types are still valid to include in sitemap. var typesToIndex = routeableContentTypeDefinitions - .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName))) + .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, System.StringComparison.Ordinal))) .Select(x => x.Name); // No advantage here in reducing with localized index. diff --git a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs index 115c7a922e5..212f3c77571 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs @@ -31,7 +31,7 @@ public PreviewPartHandler( private async Task GetPatternAsync(PreviewPart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "PreviewPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "PreviewPart", System.StringComparison.Ordinal)); var pattern = contentTypePartDefinition.GetSettings().Pattern; return pattern; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs index b297dd8834c..9045a2a9ed6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs @@ -13,7 +13,10 @@ public class AuditTrailPartSettingsDisplayDriver : ContentTypePartDefinitionDisp { public override IDisplayResult Edit(ContentTypePartDefinition model, IUpdateModel updater) { - if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name)) return null; + if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, System.StringComparison.Ordinal)) + { + return null; + } return Initialize("AuditTrailPartSettings_Edit", viewModel => { @@ -24,7 +27,10 @@ public override IDisplayResult Edit(ContentTypePartDefinition model, IUpdateMode public override async Task UpdateAsync(ContentTypePartDefinition model, UpdateTypePartEditorContext context) { - if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name)) return null; + if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, System.StringComparison.Ordinal)) + { + return null; + } var viewModel = new AuditTrailPartSettingsViewModel(); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs index 3521aba8fee..914cc0f6894 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs @@ -777,7 +777,7 @@ private async Task> GetListableContentTypeOptionsAsync( continue; } - items.Add(new SelectListItem(definition.DisplayName, definition.Name, string.Equals(definition.Name, selectedContentType))); + items.Add(new SelectListItem(definition.DisplayName, definition.Name, string.Equals(definition.Name, selectedContentType, StringComparison.Ordinal))); } return items; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs index 142587e5e05..b5d6a7e9c42 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs @@ -118,7 +118,7 @@ private async Task PopulateChangeFrequencyPriority(ContentTypesSitemapSource sou else { var sitemapEntry = source.ContentTypes - .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType)); + .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, System.StringComparison.Ordinal)); changeFrequencyValue = sitemapEntry.ChangeFrequency.ToString(); } @@ -138,7 +138,7 @@ private async Task PopulateChangeFrequencyPriority(ContentTypesSitemapSource sou else { var sitemapEntry = source.ContentTypes - .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType)); + .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, System.StringComparison.Ordinal)); priorityIntValue = sitemapEntry.Priority; } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs index c168a46710f..0453b0117ce 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs @@ -36,9 +36,9 @@ public override async Task EditAsync(ContentTypesSitemapSource s { ContentTypeName = ctd.Name, ContentTypeDisplayName = ctd.DisplayName, - IsChecked = sitemapSource.ContentTypes.Any(s => string.Equals(s.ContentTypeName, ctd.Name)), - ChangeFrequency = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name))?.ChangeFrequency ?? ChangeFrequency.Daily, - Priority = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name))?.Priority ?? 5, + IsChecked = sitemapSource.ContentTypes.Any(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)), + ChangeFrequency = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal))?.ChangeFrequency ?? ChangeFrequency.Daily, + Priority = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal))?.Priority ?? 5, }) .OrderBy(ctd => ctd.ContentTypeDisplayName) .ToArray(); @@ -53,11 +53,11 @@ public override async Task EditAsync(ContentTypesSitemapSource s .ToArray(); var limitedCtd = contentTypeDefinitions - .FirstOrDefault(ctd => string.Equals(sitemapSource.LimitedContentType.ContentTypeName, ctd.Name)); + .FirstOrDefault(ctd => string.Equals(sitemapSource.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); if (limitedCtd != null) { - var limitedEntry = limitedEntries.FirstOrDefault(le => string.Equals(le.ContentTypeName, limitedCtd.Name)); + var limitedEntry = limitedEntries.FirstOrDefault(le => string.Equals(le.ContentTypeName, limitedCtd.Name, System.StringComparison.Ordinal)); limitedEntry.Priority = sitemapSource.LimitedContentType.Priority; limitedEntry.ChangeFrequency = sitemapSource.LimitedContentType.ChangeFrequency; limitedEntry.Skip = sitemapSource.LimitedContentType.Skip; @@ -106,7 +106,7 @@ public override async Task UpdateAsync(ContentTypesSitemapSource }) .ToArray(); - var limitedEntry = model.LimitedContentTypes.FirstOrDefault(lct => string.Equals(lct.ContentTypeName, model.LimitedContentType)); + var limitedEntry = model.LimitedContentTypes.FirstOrDefault(lct => string.Equals(lct.ContentTypeName, model.LimitedContentType, System.StringComparison.Ordinal)); if (limitedEntry != null) { sitemap.LimitedContentType.ContentTypeName = limitedEntry.ContentTypeName; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceModifiedDateProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceModifiedDateProvider.cs index df230bde0f3..3e174d4689e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceModifiedDateProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceModifiedDateProvider.cs @@ -51,7 +51,7 @@ ISession session else { var typesToIndex = (await _routeableContentTypeCoordinator.ListRoutableTypeDefinitionsAsync()) - .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName))) + .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, StringComparison.Ordinal))) .Select(ctd => ctd.Name); // This is an estimate, so doesn't take into account Take/Skip values. diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs index d1deabfce75..a45ded27224 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs @@ -51,12 +51,12 @@ public async Task UpdateSitemapAsync(SitemapUpdateContext context) sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName)) + else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, System.StringComparison.Ordinal)) { sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName))) + else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, System.StringComparison.Ordinal))) { sitemap.Identifier = IdGenerator.GenerateId(); break; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs index e47ece9634e..049afdcf61a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs @@ -43,7 +43,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content type is still valid to include in sitemap. var typeIsValid = routeableContentTypeDefinitions - .Any(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name)); + .Any(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); if (typeIsValid) { @@ -61,7 +61,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content types are still valid to include in sitemap. var typesToIndex = routeableContentTypeDefinitions - .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName))) + .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, System.StringComparison.Ordinal))) .Select(x => x.Name); var queryResults = await _session.Query() diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpService.cs b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpService.cs index 0d6993f9f06..711b65c15df 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpService.cs @@ -9,7 +9,7 @@ namespace OrchardCore.Email.Services; -[Obsolete] +[Obsolete("Use IEmailService and its implementations instead")] public class SmtpService : ISmtpService { private readonly EmailProviderOptions _emailProviderOptions; diff --git a/src/OrchardCore.Modules/OrchardCore.Email/Migrations/EmailMigrations.cs b/src/OrchardCore.Modules/OrchardCore.Email/Migrations/EmailMigrations.cs index cb16d3ecf0e..7feb6a7f59b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Email/Migrations/EmailMigrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Email/Migrations/EmailMigrations.cs @@ -12,7 +12,9 @@ public class EmailMigrations : DataMigration { private const string SmtpFeatureId = "OrchardCore.Email.Smtp"; +#pragma warning disable CA1822 // Member can be static public int Create() +#pragma warning restore CA1822 { // In version 1.9, the OrchardCore.Email.Smtp was split from OrchardCore.Email. To ensure we keep the change // backward compatible, we added this migration step to auto-enable the new SMTP feature for sites that use the diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs index 51ea48644c9..6c703777265 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs @@ -67,7 +67,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, FacebookOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, FacebookDefaults.AuthenticationScheme)) + if (!string.Equals(name, FacebookDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Widgets/Drivers/FacebookPluginPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Widgets/Drivers/FacebookPluginPartDisplayDriver.cs index 8cea82e4707..4d990463934 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Widgets/Drivers/FacebookPluginPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Widgets/Drivers/FacebookPluginPartDisplayDriver.cs @@ -65,7 +65,7 @@ private async Task GetFacebookPluginPartSettingsAsyn ArgumentNullException.ThrowIfNull(part); var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(FacebookPluginPart))); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(FacebookPluginPart), StringComparison.Ordinal)); return contentTypePartDefinition.GetSettings(); } diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs index c2096bfd1d4..88c951467d3 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs @@ -51,7 +51,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, GitHubOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, GitHubDefaults.AuthenticationScheme)) + if (!string.Equals(name, GitHubDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs index 944ddd88228..458bbd27ad3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs @@ -50,7 +50,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, GoogleOptions options) { - if (!string.Equals(name, GoogleDefaults.AuthenticationScheme)) + if (!string.Equals(name, GoogleDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs index d6f32392687..850ece5ab76 100644 --- a/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs @@ -36,7 +36,7 @@ private static async ValueTask RenderHtml(IResolveFieldContext(); var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(ctx.Source.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", System.StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); var html = ctx.Source.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs index 6c9d08f9af7..e1d5ba93b01 100644 --- a/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs @@ -41,7 +41,7 @@ public override Task GetContentItemAspectAsync(ContentItemAspectContext context, try { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", System.StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); var html = part.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/AdminController.cs index 81e53934b67..fa5fd65b26c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/AdminController.cs @@ -191,7 +191,7 @@ public async Task Edit(string name) var layers = await _layerService.GetLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { @@ -236,7 +236,7 @@ public async Task EditPost(LayerEditViewModel model) if (ModelState.IsValid) { - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name, StringComparison.Ordinal)); if (layer == null) { @@ -264,7 +264,7 @@ public async Task Delete(string name) var layers = await _layerService.LoadLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/LayerRuleController.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/LayerRuleController.cs index 0e72e66b1fe..e502f305125 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/LayerRuleController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Controllers/LayerRuleController.cs @@ -57,7 +57,7 @@ public async Task Create(string name, string type, string conditi } var layers = await _layerService.GetLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { @@ -98,7 +98,7 @@ public async Task Create(LayerRuleCreateViewModel model) } var layers = await _layerService.LoadLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name, StringComparison.Ordinal)); if (layer == null) { @@ -144,7 +144,7 @@ public async Task Edit(string name, string conditionId) } var layers = await _layerService.GetLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { @@ -176,7 +176,7 @@ public async Task Edit(LayerRuleEditViewModel model) } var layers = await _layerService.LoadLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, model.Name, StringComparison.Ordinal)); if (layer == null) { @@ -215,7 +215,7 @@ public async Task Delete(string name, string conditionId) } var layers = await _layerService.LoadLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { @@ -247,7 +247,7 @@ public async Task UpdateOrder(string name, string conditionId, st } var layers = await _layerService.LoadLayersAsync(); - var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name)); + var layer = layers.Layers.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.Ordinal)); if (layer == null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Handlers/ContainedPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Handlers/ContainedPartHandler.cs index 8e986cd4218..f91fc6dfe89 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Handlers/ContainedPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Handlers/ContainedPartHandler.cs @@ -32,7 +32,7 @@ public override async Task CloningAsync(CloneContentContext context) { var contentDefinitionManager = _serviceProvider.GetRequiredService(); var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(listContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "ListPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "ListPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); if (settings.EnableOrdering) { diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/RemotePublishing/MetaWeblogHandler.cs b/src/OrchardCore.Modules/OrchardCore.Lists/RemotePublishing/MetaWeblogHandler.cs index 4c76cb2caf0..e49ea1f7480 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/RemotePublishing/MetaWeblogHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/RemotePublishing/MetaWeblogHandler.cs @@ -486,7 +486,7 @@ private async Task CheckAccessAsync(Permission permission, ClaimsPrincipal user, private async Task> GetContainedContentTypesAsync(ContentItem contentItem) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "ListPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "ListPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); var contentTypes = settings.ContainedContentTypes ?? []; diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs index 9614f1a2ee2..1f373225dba 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs @@ -47,7 +47,7 @@ private static async ValueTask ToHtml(IResolveFieldContext(); var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(ctx.Source.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", System.StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); // The default Markdown option is to entity escape html diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs index 48a9a0db63a..2ac6e5c3c2c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs @@ -56,8 +56,8 @@ private static async ValueTask ToHtml(IResolveFieldContext string.Equals(x.Name, partName)); - var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName)); + var contentPartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.Name, partName, System.StringComparison.Ordinal)); + var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, System.StringComparison.Ordinal)); var settings = contentPartFieldDefinition.GetSettings(); diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs index 4937def4904..31f2c6ccacd 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs @@ -49,7 +49,7 @@ public override Task GetContentItemAspectAsync(ContentItemAspectContext context, try { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart")); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", System.StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); // The default Markdown option is to entity escape html diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Services/ManageMediaFolderAuthorizationHandler.cs b/src/OrchardCore.Modules/OrchardCore.Media/Services/ManageMediaFolderAuthorizationHandler.cs index dfd98c889e2..13272151dda 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Services/ManageMediaFolderAuthorizationHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Services/ManageMediaFolderAuthorizationHandler.cs @@ -101,7 +101,7 @@ private bool IsAuthorizedFolder(string authorizedFolder, string childPath) childPath = _fileStore.NormalizePath(childPath) .TrimEnd(_pathSeparator) + _pathSeparator; - return childPath.Equals(authorizedFolder); + return childPath.Equals(authorizedFolder, StringComparison.Ordinal); } private bool IsDescendantOfauthorizedFolder(string authorizedFolder, string childPath) diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs index 95daa4d3b1b..bbbbbfedbe6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs @@ -56,7 +56,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, MicrosoftIdentityOptions options) { - if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd)) + if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, System.StringComparison.Ordinal)) { return; } @@ -81,7 +81,7 @@ public void Configure(string name, MicrosoftIdentityOptions options) public void Configure(string name, PolicySchemeOptions options) { - if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd)) + if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, System.StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs index 4d288619e56..3b2fb3f83c3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs @@ -52,7 +52,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, MicrosoftAccountOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, MicrosoftAccountDefaults.AuthenticationScheme)) + if (!string.Equals(name, MicrosoftAccountDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdClientConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdClientConfiguration.cs index b8876db0f2b..a70f67751eb 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdClientConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdClientConfiguration.cs @@ -52,7 +52,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, OpenIdConnectOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, OpenIdConnectDefaults.AuthenticationScheme)) + if (!string.Equals(name, OpenIdConnectDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdValidationConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdValidationConfiguration.cs index 18f67ccc313..20ebb006db4 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdValidationConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Configuration/OpenIdValidationConfiguration.cs @@ -181,7 +181,7 @@ public void Configure(OpenIddictValidationOptions options) } var tenant = _runningShellTable.Match(HostString.FromUriComponent(uri), uri.AbsolutePath); - if (tenant == null || !string.Equals(tenant.Name, settings.Tenant)) + if (tenant == null || !string.Equals(tenant.Name, settings.Tenant, StringComparison.Ordinal)) { throw new SecurityTokenInvalidIssuerException("The token issuer is not valid."); } @@ -203,7 +203,7 @@ public void Configure(OpenIddictValidationDataProtectionOptions options) // If the tokens are issued by an authorization server located in a separate tenant, // resolve the isolated data protection provider associated with the specified tenant. if (!string.IsNullOrEmpty(settings.Tenant) && - !string.Equals(settings.Tenant, _shellSettings.Name)) + !string.Equals(settings.Tenant, _shellSettings.Name, StringComparison.Ordinal)) { CreateTenantScope(settings.Tenant).UsingAsync(async scope => { @@ -236,7 +236,7 @@ public void Configure(ApiAuthorizationOptions options) private ShellScope CreateTenantScope(string tenant) { // Optimization: if the specified name corresponds to the current tenant, use the current 'ShellScope'. - if (string.IsNullOrEmpty(tenant) || string.Equals(tenant, _shellSettings.Name)) + if (string.IsNullOrEmpty(tenant) || string.Equals(tenant, _shellSettings.Name, StringComparison.Ordinal)) { return ShellScope.Current; } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/AccessController.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/AccessController.cs index 6e3cc60446d..d23b6b199f0 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/AccessController.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/AccessController.cs @@ -571,7 +571,7 @@ private async Task ExchangeAuthorizationCodeOrRefreshTokenGrantTy if (request.IsRefreshTokenGrantType()) { var type = info.Principal.FindFirst(OpenIdConstants.Claims.EntityType)?.Value; - if (!string.Equals(type, OpenIdConstants.EntityTypes.User)) + if (!string.Equals(type, OpenIdConstants.EntityTypes.User, StringComparison.Ordinal)) { return Forbid(new AuthenticationProperties(new Dictionary { diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ScopeController.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ScopeController.cs index 7b5461825c3..4a31540ed34 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ScopeController.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/ScopeController.cs @@ -99,7 +99,7 @@ public async Task Create(string returnUrl = null) { model.Tenants.Add(new CreateOpenIdScopeViewModel.TenantEntry { - Current = string.Equals(tenant.Name, _shellSettings.Name), + Current = string.Equals(tenant.Name, _shellSettings.Name, StringComparison.Ordinal), Name = tenant.Name }); } @@ -141,7 +141,7 @@ public async Task Create(CreateOpenIdScopeViewModel model, string descriptor.Resources.UnionWith(model.Tenants .Where(tenant => tenant.Selected) - .Where(tenant => !string.Equals(tenant.Name, _shellSettings.Name)) + .Where(tenant => !string.Equals(tenant.Name, _shellSettings.Name, StringComparison.Ordinal)) .Select(tenant => OpenIdConstants.Prefixes.Tenant + tenant.Name)); await _scopeManager.CreateAsync(descriptor); @@ -186,7 +186,7 @@ from resource in resources { model.Tenants.Add(new EditOpenIdScopeViewModel.TenantEntry { - Current = string.Equals(tenant.Name, _shellSettings.Name), + Current = string.Equals(tenant.Name, _shellSettings.Name, StringComparison.Ordinal), Name = tenant.Name, Selected = resources.Contains(OpenIdConstants.Prefixes.Tenant + tenant.Name) }); @@ -213,9 +213,7 @@ public async Task Edit(EditOpenIdScopeViewModel model, string ret if (ModelState.IsValid) { var other = await _scopeManager.FindByNameAsync(model.Name); - if (other != null && !string.Equals( - await _scopeManager.GetIdAsync(other), - await _scopeManager.GetIdAsync(scope))) + if (other != null && !string.Equals(await _scopeManager.GetIdAsync(other), await _scopeManager.GetIdAsync(scope), StringComparison.Ordinal)) { ModelState.AddModelError(nameof(model.Name), S["The name is already taken by another scope."]); } @@ -243,7 +241,7 @@ await _scopeManager.GetIdAsync(scope))) descriptor.Resources.UnionWith(model.Tenants .Where(tenant => tenant.Selected) - .Where(tenant => !string.Equals(tenant.Name, _shellSettings.Name)) + .Where(tenant => !string.Equals(tenant.Name, _shellSettings.Name, StringComparison.Ordinal)) .Select(tenant => OpenIdConstants.Prefixes.Tenant + tenant.Name)); await _scopeManager.UpdateAsync(scope, descriptor); diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs index 7def02963b3..201621e04e0 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs @@ -47,7 +47,7 @@ public async Task Me() // Ensure the access token represents a user and not an application. var type = principal.FindFirst(OpenIdConstants.Claims.EntityType)?.Value; - if (!string.Equals(type, OpenIdConstants.EntityTypes.User)) + if (!string.Equals(type, OpenIdConstants.EntityTypes.User, System.StringComparison.Ordinal)) { return Forbid(new AuthenticationProperties(new Dictionary { diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs index 52fbef3f6d3..4a63ac63eb3 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs @@ -178,7 +178,7 @@ public async Task> ValidateSettingsAsync(OpenId // If a tenant was specified, ensure it is valid, that the OpenID server feature // was enabled and that at least a scope linked with the current tenant exists. if (!string.IsNullOrEmpty(settings.Tenant) && - !string.Equals(settings.Tenant, _shellSettings.Name)) + !string.Equals(settings.Tenant, _shellSettings.Name, StringComparison.Ordinal)) { if (!_shellHost.TryGetSettings(settings.Tenant, out var shellSettings)) { diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleStore.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleStore.cs index de696464c1c..8b8ac87027f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleStore.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleStore.cs @@ -84,8 +84,8 @@ public async Task DeleteAsync(IRole role, CancellationToken canc var roleToRemove = (Role)role; - if (string.Equals(roleToRemove.NormalizedRoleName, "ANONYMOUS") || - string.Equals(roleToRemove.NormalizedRoleName, "AUTHENTICATED")) + if (string.Equals(roleToRemove.NormalizedRoleName, "ANONYMOUS", StringComparison.Ordinal) || + string.Equals(roleToRemove.NormalizedRoleName, "AUTHENTICATED", StringComparison.Ordinal)) { return IdentityResult.Failed(new IdentityError { Description = S["Can't delete system roles."] }); } diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs b/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs index 2a30f9ebe0f..b24766f42ea 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/ViewModels/PermissionGroupKey.cs @@ -31,6 +31,6 @@ public override bool Equals(object obj) { var other = obj as PermissionGroupKey; - return other != null && Key.Equals(other.Key); + return other != null && Key.Equals(other.Key, StringComparison.Ordinal); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Rules/Services/StringOperatorComparer.cs b/src/OrchardCore.Modules/OrchardCore.Rules/Services/StringOperatorComparer.cs index f2990d374e0..ceeeb32be65 100644 --- a/src/OrchardCore.Modules/OrchardCore.Rules/Services/StringOperatorComparer.cs +++ b/src/OrchardCore.Modules/OrchardCore.Rules/Services/StringOperatorComparer.cs @@ -7,7 +7,7 @@ public class StringEqualsOperatorComparer : OperatorComparer conditionOperator.CaseSensitive ? - string.Equals(a, b) : + string.Equals(a, b, StringComparison.Ordinal) : string.Equals(a, b, StringComparison.OrdinalIgnoreCase); } @@ -15,7 +15,7 @@ public class StringNotEqualsOperatorComparer : OperatorComparer conditionOperator.CaseSensitive ? - !string.Equals(a, b) : + !string.Equals(a, b, StringComparison.Ordinal) : !string.Equals(a, b, StringComparison.OrdinalIgnoreCase); } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs index b0bdf7a7a52..53af2595d4b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs @@ -48,7 +48,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals("ContentPickerField", model.FieldDefinition.Name); + return string.Equals("ContentPickerField", model.FieldDefinition.Name, System.StringComparison.Ordinal); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs index 9447a0be542..5f273b15e99 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs @@ -44,7 +44,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals("ContentPickerField", model.FieldDefinition.Name); + return string.Equals("ContentPickerField", model.FieldDefinition.Name, System.StringComparison.Ordinal); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Providers/LocaleShortcodeProvider.cs b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Providers/LocaleShortcodeProvider.cs index 9ac31934e53..bd3f3af1f4f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Providers/LocaleShortcodeProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Providers/LocaleShortcodeProvider.cs @@ -31,7 +31,7 @@ public ValueTask EvaluateAsync(string identifier, Arguments arguments, s // Fallback to parent culture, if the current culture is en-CA and the shortcode targets en, the html will be output. do { - if (currentCulture.Name.Equals(language, StringComparison.InvariantCultureIgnoreCase)) + if (currentCulture.Name.Equals(language, StringComparison.OrdinalIgnoreCase)) { return new ValueTask(content); } @@ -42,7 +42,7 @@ public ValueTask EvaluateAsync(string identifier, Arguments arguments, s } else { - if (currentCulture.Name.Equals(language, StringComparison.InvariantCultureIgnoreCase)) + if (currentCulture.Name.Equals(language, StringComparison.OrdinalIgnoreCase)) { return new ValueTask(content); } diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs index 5463e1e87df..feccd40b20c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs @@ -52,12 +52,12 @@ public async Task UpdateSitemapAsync(SitemapUpdateContext context) sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName)) + else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, System.StringComparison.Ordinal)) { sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName))) + else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, System.StringComparison.Ordinal))) { sitemap.Identifier = IdGenerator.GenerateId(); break; diff --git a/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs index 992cafaf223..c6c43ea0776 100644 --- a/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs @@ -102,7 +102,7 @@ private async Task SetTitleAsync(TitlePart part) private async Task GetSettingsAsync(TitlePart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(TitlePart))); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(TitlePart), System.StringComparison.Ordinal)); return contentTypePartDefinition.GetSettings(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterClientMessageHandler.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterClientMessageHandler.cs index 000a11f210c..88af336f70c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterClientMessageHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Services/TwitterClientMessageHandler.cs @@ -100,7 +100,9 @@ public async Task ConfigureOAuthAsync(HttpRequestMessage request) var secret = string.Concat(_twitterSettings.ConsumerSecret, "&", _twitterSettings.AccessTokenSecret); +#pragma warning disable CA5350 // Do not use weak cryptographic hashing algorithm var signature = Convert.ToBase64String(HMACSHA1.HashData(key: Encoding.UTF8.GetBytes(secret), source: Encoding.UTF8.GetBytes(baseString))); +#pragma warning restore CA5350 var sb = new StringBuilder(); sb.Append("oauth_consumer_key=\"").Append(Uri.EscapeDataString(_twitterSettings.ConsumerKey)).Append("\", "); diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Signin/Configuration/TwitterOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Signin/Configuration/TwitterOptionsConfiguration.cs index 5035132fa3f..bb6fe1f0a4c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Signin/Configuration/TwitterOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Signin/Configuration/TwitterOptionsConfiguration.cs @@ -76,7 +76,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, TwitterOptions options) { - if (!string.Equals(name, TwitterDefaults.AuthenticationScheme)) + if (!string.Equals(name, TwitterDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AuthenticatorAppController.cs b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AuthenticatorAppController.cs index 9acf9a18cb6..07e5c0c0fd6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AuthenticatorAppController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Controllers/AuthenticatorAppController.cs @@ -191,7 +191,9 @@ private async Task GenerateQrCodeUriAsync(string displayName, string unf return string.Format( CultureInfo.InvariantCulture, +#pragma warning disable CA1863 // Cache a 'CompositeFormat' for repeated use in this formatting operation AuthenticatorUriFormat, +#pragma warning restore CA1863 _urlEncoder.Encode(issuer), _urlEncoder.Encode(displayName), unformattedKey, diff --git a/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs b/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs index 10bce64a4a1..b4384e3c0c5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs +++ b/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs @@ -60,7 +60,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) // ContentCard_Edit__LandingPage__BagPart__Service, ContentCard_Edit__Form__FlowPart__Label contentCardEditor.Metadata.Alternates.Add($"{ContentCardEdit}__{parentContentType}__{collectionType}__{contentType}"); - if (!string.IsNullOrWhiteSpace(namedPart) && !(namedPart.Equals(collectionType))) + if (!string.IsNullOrWhiteSpace(namedPart) && !(namedPart.Equals(collectionType, System.StringComparison.Ordinal))) { // Define edit card shape for selected child with specific type and partname per parent content type // ContentCard_Edit__[ParentContentType]__[PartName] @@ -118,7 +118,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) // e.g. ContentCard_Frame__Page__FlowPart__Container, ContentCard_Frame__LandingPage__BagPart__Service, ContentCard_Frame__Form__FlowPart__Label contentCardFrame.Metadata.Alternates.Add($"{ContentCardFrame}__{parentContentType}__{collectionType}__{contentType}"); - if (!string.IsNullOrWhiteSpace(namedPart) && !namedPart.Equals(collectionType)) + if (!string.IsNullOrWhiteSpace(namedPart) && !namedPart.Equals(collectionType, System.StringComparison.Ordinal)) { // Define frame card shape for child with specific partname and parent content type // ContentCard_Frame__[ParentContentType]__[PartName] diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs index da4b5b24a12..fcc025bae87 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs @@ -7,7 +7,7 @@ public class LocalizedStringComparer : IEqualityComparer { public bool Equals(LocalizedString x, LocalizedString y) { - return x.Name.Equals(y.Name); + return x.Name.Equals(y.Name, System.StringComparison.Ordinal); } public int GetHashCode(LocalizedString obj) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentFieldDisplayDriver.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentFieldDisplayDriver.cs index 67c8e1b6df1..646221fea20 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentFieldDisplayDriver.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentFieldDisplayDriver.cs @@ -131,8 +131,8 @@ public override ShapeResult Factory(string shapeType, Func IContentFieldDisplayDriver.BuildDisplayAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, BuildDisplayContext context) { - if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) && - !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name)) + if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal) && + !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal)) { return Task.FromResult(default(IDisplayResult)); } @@ -160,8 +160,8 @@ Task IContentFieldDisplayDriver.BuildDisplayAsync(ContentPart co Task IContentFieldDisplayDriver.BuildEditorAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, BuildEditorContext context) { - if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) && - !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name)) + if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal) && + !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal)) { return Task.FromResult(default(IDisplayResult)); } @@ -190,8 +190,8 @@ Task IContentFieldDisplayDriver.BuildEditorAsync(ContentPart con async Task IContentFieldDisplayDriver.UpdateEditorAsync(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition, ContentTypePartDefinition typePartDefinition, UpdateEditorContext context) { - if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) && - !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name)) + if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal) && + !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal)) { return null; } diff --git a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/ServiceCollectionExtensions.cs index e4b287bd54f..a88b7a07230 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/ServiceCollectionExtensions.cs @@ -32,10 +32,10 @@ public static IServiceCollection AddContentGraphQL(this IServiceCollection servi return services; } - public static void AddWhereInputIndexPropertyProvider(this IServiceCollection services) - where IIndexType : MapIndex + public static void AddWhereInputIndexPropertyProvider(this IServiceCollection services) + where TIndexType : MapIndex { - services.AddSingleton>(); + services.AddSingleton>(); } /// diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs index 48604539fca..1a95b671d6a 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs @@ -37,7 +37,7 @@ public abstract class ContentPartFieldDefinitionDisplayDriver : ContentP { public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals(typeof(TField).Name, model.FieldDefinition.Name); + return string.Equals(typeof(TField).Name, model.FieldDefinition.Name, System.StringComparison.Ordinal); } } } diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs index 481a49cadb2..2dadb8b6d0f 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs @@ -33,7 +33,7 @@ public abstract class ContentTypePartDefinitionDisplayDriver : ContentTyp { public override bool CanHandleModel(ContentTypePartDefinition model) { - return string.Equals(typeof(TPart).Name, model.PartDefinition.Name); + return string.Equals(typeof(TPart).Name, model.PartDefinition.Name, System.StringComparison.Ordinal); } } } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs index 78b18835e1a..4871445312f 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/ShapePlacementStrategy/ShapePlacementParsingStrategy.cs @@ -129,7 +129,7 @@ public static Func BuildPredicate(Func x.Key.Equals(term.Key)); + var providersForTerm = placementMatchProviders.Where(x => x.Key.Equals(term.Key, StringComparison.Ordinal)); if (providersForTerm.Any()) { var expression = term.Value; diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/AlternatesCollection.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/AlternatesCollection.cs index caca76f2028..ef47101722a 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/AlternatesCollection.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Shapes/AlternatesCollection.cs @@ -11,7 +11,7 @@ namespace OrchardCore.DisplayManagement.Shapes /// public class AlternatesCollection : IEnumerable { - public static AlternatesCollection Empty = []; + public static readonly AlternatesCollection Empty = []; private KeyedAlternateCollection _collection; diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Zones/FlatPositionComparer.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Zones/FlatPositionComparer.cs index fa911de9c41..0db7fe032a6 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Zones/FlatPositionComparer.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Zones/FlatPositionComparer.cs @@ -89,12 +89,12 @@ private static string NormalizeKnownPartitions(string partition) return partition; } - if (string.Compare(partition, "before", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(partition, "before", StringComparison.OrdinalIgnoreCase)) { return "-9999"; } - if (string.Compare(partition, "after", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(partition, "after", StringComparison.OrdinalIgnoreCase)) { return "9999"; } diff --git a/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs b/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs index 37b7d638d06..320cbee0e7e 100644 --- a/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs +++ b/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs @@ -13,8 +13,8 @@ public abstract class ContentFieldIndexHandler : IContentFieldIndexHandl { Task IContentFieldIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildIndexContext context, IContentIndexSettings settings) { - if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) && - !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name)) + if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, System.StringComparison.Ordinal) && + !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, System.StringComparison.Ordinal)) { return Task.CompletedTask; } diff --git a/src/OrchardCore/OrchardCore.Media.Core/Services/MediaSizeLimitAttribute.cs b/src/OrchardCore/OrchardCore.Media.Core/Services/MediaSizeLimitAttribute.cs index ba1414cb3ef..97c2d1fed30 100644 --- a/src/OrchardCore/OrchardCore.Media.Core/Services/MediaSizeLimitAttribute.cs +++ b/src/OrchardCore/OrchardCore.Media.Core/Services/MediaSizeLimitAttribute.cs @@ -23,7 +23,7 @@ public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) return new InternalMediaSizeFilter(options.Value.MaxFileSize); } - private class InternalMediaSizeFilter : IAuthorizationFilter, IRequestFormLimitsPolicy + private sealed class InternalMediaSizeFilter : IAuthorizationFilter, IRequestFormLimitsPolicy { private readonly long _maxFileSize; @@ -55,7 +55,7 @@ public void OnAuthorization(AuthorizationFilterContext context) } var effectiveRequestSizePolicy = context.FindEffectivePolicy(); - if (effectiveRequestSizePolicy == null || effectiveRequestSizePolicy == this) + if (effectiveRequestSizePolicy == null) { // Will only be available when running OutOfProcess with Kestrel. var maxRequestBodySizeFeature = context.HttpContext.Features.Get(); diff --git a/src/OrchardCore/OrchardCore.Mvc.Core/ModuleProjectRazorFileProvider.cs b/src/OrchardCore/OrchardCore.Mvc.Core/ModuleProjectRazorFileProvider.cs index f02f499c934..f1ed90d4d0a 100644 --- a/src/OrchardCore/OrchardCore.Mvc.Core/ModuleProjectRazorFileProvider.cs +++ b/src/OrchardCore/OrchardCore.Mvc.Core/ModuleProjectRazorFileProvider.cs @@ -216,7 +216,7 @@ public IChangeToken Watch(string filter) // The view engine uses a watch on "Pages/**/*.cshtml" but only for razor pages. // So here, we only use file providers for modules which have a "Pages" folder. - else if (path.Equals("Pages/**/*.cshtml")) + else if (path.Equals("Pages/**/*.cshtml", StringComparison.Ordinal)) { var changeTokens = new List(); diff --git a/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs b/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs index d24866c5823..d5eaedd58e0 100644 --- a/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs +++ b/src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/ResourceDefinition.cs @@ -358,9 +358,9 @@ public override bool Equals(object obj) } var that = (ResourceDefinition)obj; - return string.Equals(that.Name, Name) && - string.Equals(that.Type, Type) && - string.Equals(that.Version, Version); + return string.Equals(that.Name, Name, StringComparison.Ordinal) && + string.Equals(that.Type, Type, StringComparison.Ordinal) && + string.Equals(that.Version, Version, StringComparison.Ordinal); } public override int GetHashCode() diff --git a/src/OrchardCore/OrchardCore.ResourceManagement/ResourceDictionary.cs b/src/OrchardCore/OrchardCore.ResourceManagement/ResourceDictionary.cs index 125ab3d95e2..66d0e6b5334 100644 --- a/src/OrchardCore/OrchardCore.ResourceManagement/ResourceDictionary.cs +++ b/src/OrchardCore/OrchardCore.ResourceManagement/ResourceDictionary.cs @@ -4,7 +4,9 @@ namespace OrchardCore.ResourceManagement { +#pragma warning disable CA1010 // Type 'ResourceDictionary' directly or indirectly inherits 'ICollection' without implementing any of 'ICollection', 'IReadOnlyCollection'. Publicly-visible types should implement the generic version to broaden usability. public class ResourceDictionary : OrderedDictionary +#pragma warning restore CA1010 { private readonly Stack _expanding = new(); diff --git a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs index fd6521aecaa..eb420a4376f 100644 --- a/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs +++ b/src/OrchardCore/OrchardCore.Search.AzureAI.Core/Services/AzureAISearchIndexDocumentManager.cs @@ -220,7 +220,7 @@ public async Task> GetMappingsAsync(string[] indexe return mapping; } - private IEnumerable CreateSearchDocuments(IEnumerable indexDocuments, Dictionary> mappings) + private static IEnumerable CreateSearchDocuments(IEnumerable indexDocuments, Dictionary> mappings) { foreach (var indexDocument in indexDocuments) { @@ -228,7 +228,7 @@ private IEnumerable CreateSearchDocuments(IEnumerable> mappingDictionary) + private static SearchDocument CreateSearchDocument(DocumentIndex documentIndex, Dictionary> mappingDictionary) { var doc = new SearchDocument() { diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs index 0369070a359..e55e79d9a67 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs @@ -108,7 +108,7 @@ await _elasticIndexManager.SearchAsync(indexName, async elasticClient => { ContentItemId = doc["ContentItemId"].ToString(), DisplayText = doc["Content.ContentItem.DisplayText.keyword"].ToString(), - HasPublished = doc["Content.ContentItem.Published"].ToString().ToLowerInvariant().Equals("true") + HasPublished = doc["Content.ContentItem.Published"].ToString().ToLowerInvariant().Equals("true", System.StringComparison.Ordinal) }); } } diff --git a/src/OrchardCore/OrchardCore/Extensions/Features/FeatureHash.cs b/src/OrchardCore/OrchardCore/Extensions/Features/FeatureHash.cs index 341fb2c043e..8f06c2d13d3 100644 --- a/src/OrchardCore/OrchardCore/Extensions/Features/FeatureHash.cs +++ b/src/OrchardCore/OrchardCore/Extensions/Features/FeatureHash.cs @@ -50,7 +50,7 @@ public async Task GetFeatureHashAsync(string featureId) { var enabledFeatures = await _featureManager.GetEnabledFeaturesAsync(); - enabled = enabledFeatures.Any(x => x.Id.Equals(featureId)); + enabled = enabledFeatures.Any(x => x.Id.Equals(featureId, StringComparison.Ordinal)); _memoryCache.Set(cacheKey, enabled); } diff --git a/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs b/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs index b9cd33e8845..1e7a0c2df72 100644 --- a/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs +++ b/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs @@ -325,7 +325,7 @@ await shellScope.UsingAsync(async scope => } settings ??= task.GetDefaultSettings(); - if (scheduler.Released || !scheduler.Settings.Schedule.Equals(settings.Schedule)) + if (scheduler.Released || !scheduler.Settings.Schedule.Equals(settings.Schedule, StringComparison.Ordinal)) { scheduler.ReferenceTime = referenceTime; } diff --git a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/LifetimeTrackingHttpMessageHandler.cs b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/LifetimeTrackingHttpMessageHandler.cs index 68190dbc5b1..212a4933b22 100644 --- a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/LifetimeTrackingHttpMessageHandler.cs +++ b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/LifetimeTrackingHttpMessageHandler.cs @@ -15,7 +15,9 @@ public LifetimeTrackingHttpMessageHandler(HttpMessageHandler innerHandler) { } +#pragma warning disable CA2215 // Dispose methods should call base class dispose protected override void Dispose(bool disposing) +#pragma warning restore CA2215 { // The lifetime of this is tracked separately by ActiveHandlerTrackingEntry. } diff --git a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/TenantHttpClientFactory.cs b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/TenantHttpClientFactory.cs index 07359c8104a..752de2a90a9 100644 --- a/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/TenantHttpClientFactory.cs +++ b/src/OrchardCore/OrchardCore/Modules/Overrides/HttpClient/TenantHttpClientFactory.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.Http { - internal class TenantHttpClientFactory : IHttpClientFactory, IHttpMessageHandlerFactory, IDisposable + internal sealed class TenantHttpClientFactory : IHttpClientFactory, IHttpMessageHandlerFactory, IDisposable { private static readonly TimerCallback _cleanupCallback = (s) => ((TenantHttpClientFactory)s!).CleanupTimer_Tick(); private IServiceProvider? _services; @@ -242,13 +242,13 @@ internal void ExpiryTimer_Tick(object? state) } // Internal so it can be overridden in tests. - internal virtual void StartHandlerEntryTimer(ActiveHandlerTrackingEntry entry) + internal void StartHandlerEntryTimer(ActiveHandlerTrackingEntry entry) { entry.StartExpiryTimer(_expiryCallback); } // Internal so it can be overridden in tests. - internal virtual void StartCleanupTimer() + internal void StartCleanupTimer() { lock (_cleanupTimerLock) { @@ -257,7 +257,7 @@ internal virtual void StartCleanupTimer() } // Internal so it can be overridden in tests. - internal virtual void StopCleanupTimer() + internal void StopCleanupTimer() { lock (_cleanupTimerLock) { diff --git a/test/OrchardCore.Abstractions.Tests/Modules/Manifest/ModuleAttributeTests.cs b/test/OrchardCore.Abstractions.Tests/Modules/Manifest/ModuleAttributeTests.cs index 25e59bd5123..d4bafa397ef 100644 --- a/test/OrchardCore.Abstractions.Tests/Modules/Manifest/ModuleAttributeTests.cs +++ b/test/OrchardCore.Abstractions.Tests/Modules/Manifest/ModuleAttributeTests.cs @@ -35,7 +35,9 @@ public ModuleAttributeTests(ITestOutputHelper outputHelper) : base(outputHelper) #pragma warning disable CA1018 // Specify AttributeUsage... // No need since the attribute is only here in order to verify Prefix extraction +#pragma warning disable CA1710 // Rename to end in 'Attribute' public class TestAttributePrefix : Attribute { } +#pragma warning restore CA1710 #pragma warning restore CA1018 // TODO: MWP: could probably separate this between classes, Theory at one level, InlineData at another... @@ -644,7 +646,7 @@ public virtual void Csproj_OrchardCoreModules_MSBuild_ItemLists() Assert.Contains(features, _ => _.Id == string.Join(".", baseId, One) && _.Name == _.Id && - _.Category.Equals(Two, StringComparison.CurrentCultureIgnoreCase) && + _.Category.Equals(Two, StringComparison.OrdinalIgnoreCase) && _.InternalPriority == _3 && _.Description == four && _.Dependencies.SequenceEqual(GetValues(five, six, seven)) && diff --git a/test/OrchardCore.Tests/Apis/Context/AuthenticationContext.cs b/test/OrchardCore.Tests/Apis/Context/AuthenticationContext.cs index 22ec2155240..71ca0c64661 100644 --- a/test/OrchardCore.Tests/Apis/Context/AuthenticationContext.cs +++ b/test/OrchardCore.Tests/Apis/Context/AuthenticationContext.cs @@ -66,7 +66,7 @@ protected override Task HandleRequirementAsync(AuthorizationHandlerContext conte return Task.CompletedTask; } - private void GetGrantingNamesInternal(Permission permission, HashSet stack) + private static void GetGrantingNamesInternal(Permission permission, HashSet stack) { // The given name is tested stack.Add(permission.Name); diff --git a/test/OrchardCore.Tests/Apis/Context/SiteContext.cs b/test/OrchardCore.Tests/Apis/Context/SiteContext.cs index 845c410170d..827aa1e9336 100644 --- a/test/OrchardCore.Tests/Apis/Context/SiteContext.cs +++ b/test/OrchardCore.Tests/Apis/Context/SiteContext.cs @@ -161,7 +161,9 @@ public Task DeleteContentItem(string contentItemId) return Client.DeleteAsync("api/content/" + contentItemId); } +#pragma warning disable CA1816 // Change SiteContext.Dispose() to call GC.SuppressFinalize(object). This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it. public void Dispose() +#pragma warning restore CA1816 { Client?.Dispose(); } diff --git a/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs b/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs index 26afec46568..df8292c826f 100644 --- a/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs +++ b/test/OrchardCore.Tests/Apis/GraphQL/Blog/BlogPostTests.cs @@ -195,7 +195,7 @@ public async Task ShouldQueryByStatus() result = await context.GraphQLClient.Content .Query("blogPost(status: LATEST) { displayText, published }"); - Assert.Equal(2, result["data"]["blogPost"].AsArray().Count()); + Assert.Equal(2, result["data"]["blogPost"].AsArray().Count); } [Fact] diff --git a/test/OrchardCore.Tests/Apis/GraphQL/Queries/RecentBlogPostsQueryTests.cs b/test/OrchardCore.Tests/Apis/GraphQL/Queries/RecentBlogPostsQueryTests.cs index cce316c6e55..350362a26de 100644 --- a/test/OrchardCore.Tests/Apis/GraphQL/Queries/RecentBlogPostsQueryTests.cs +++ b/test/OrchardCore.Tests/Apis/GraphQL/Queries/RecentBlogPostsQueryTests.cs @@ -37,7 +37,7 @@ public async Task ShouldListBlogPostWhenCallingAQuery() var nodes = result["data"]["recentBlogPosts"]; - Assert.Equal(2, nodes.AsArray().Count()); + Assert.Equal(2, nodes.AsArray().Count); Assert.Equal("Some sorta blogpost in a Query!", nodes[0]["displayText"].ToString()); Assert.Equal("Man must explore, and this is exploration at its greatest", nodes[1]["displayText"].ToString()); } diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaEventTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaEventTests.cs index 1ecf93db761..aa7da31adf3 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaEventTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaEventTests.cs @@ -19,7 +19,9 @@ public async Task DisposesMediaCreatingStreams() var path = string.Empty; // This stream will be disposed by the creating stream, or the finally block. +#pragma warning disable CA1859 // Change type of variable 'inputStream' from 'System.IO.Stream' to 'System.IO.MemoryStream?' for improved performance Stream inputStream = null; +#pragma warning restore CA1859 try { inputStream = new MemoryStream(); diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs index c4a36598795..461f0ae53fe 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Media/MediaTokenTests.cs @@ -128,7 +128,7 @@ public void ShouldGenerateConsistentToken() Assert.Equal(tokenizedPath1, tokenizedPath2); } - private IServiceProvider CreateServiceProvider() + private ServiceProvider CreateServiceProvider() { var services = new ServiceCollection(); diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Resources/SubResourceIntegrityTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Resources/SubResourceIntegrityTests.cs index 9ca6d1d546d..4fcf01b3e13 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Resources/SubResourceIntegrityTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Resources/SubResourceIntegrityTests.cs @@ -41,7 +41,7 @@ async Task ValidateSubResourceIntegrityAsync(string resourceType) { var resourceIntegrity = await GetSubResourceIntegrityAsync(httpClient, resourceDefinition.UrlCdnDebug); - Assert.True(resourceIntegrity.Equals(resourceDefinition.CdnDebugIntegrity), + Assert.True(resourceIntegrity.Equals(resourceDefinition.CdnDebugIntegrity, StringComparison.Ordinal), $"The {resourceType} {resourceDefinition.UrlCdnDebug} has invalid SRI hash, please use '{resourceIntegrity}' instead."); } @@ -49,7 +49,7 @@ async Task ValidateSubResourceIntegrityAsync(string resourceType) { var resourceIntegrity = await GetSubResourceIntegrityAsync(httpClient, resourceDefinition.UrlCdn); - Assert.True(resourceIntegrity.Equals(resourceDefinition.CdnIntegrity), + Assert.True(resourceIntegrity.Equals(resourceDefinition.CdnIntegrity, StringComparison.Ordinal), $"The {resourceType} {resourceDefinition.UrlCdn} has invalid SRI hash, please use '{resourceIntegrity}' instead."); } } diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Security/Extensions/SecurityHeadersApplicationBuilderExtensionsTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Security/Extensions/SecurityHeadersApplicationBuilderExtensionsTests.cs index 9ce20790e65..2028940ced3 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Security/Extensions/SecurityHeadersApplicationBuilderExtensionsTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Security/Extensions/SecurityHeadersApplicationBuilderExtensionsTests.cs @@ -96,7 +96,7 @@ public void SecurityHeadersShouldBeAddedAccordingBuildConfiguration() Assert.Equal(ReferrerPolicyValue.Origin, context.Response.Headers[SecurityHeaderNames.ReferrerPolicy]); } - private static IApplicationBuilder CreateApplicationBuilder() + private static ApplicationBuilder CreateApplicationBuilder() { var services = new ServiceCollection(); var serviceProvider = services.BuildServiceProvider(); diff --git a/test/OrchardCore.Tests/Modules/OrchardCore.Tenants/ApiControllerTests.cs b/test/OrchardCore.Tests/Modules/OrchardCore.Tenants/ApiControllerTests.cs index 81ad7396632..0a066ddc953 100644 --- a/test/OrchardCore.Tests/Modules/OrchardCore.Tenants/ApiControllerTests.cs +++ b/test/OrchardCore.Tests/Modules/OrchardCore.Tenants/ApiControllerTests.cs @@ -180,7 +180,7 @@ private ApiController CreateController() }; } - private static HttpContext CreateHttpContext() + private static DefaultHttpContext CreateHttpContext() { var httpContext = new DefaultHttpContext { diff --git a/test/OrchardCore.Tests/OrchardCore.Environment.Cache/CacheScopeManagerTests.cs b/test/OrchardCore.Tests/OrchardCore.Environment.Cache/CacheScopeManagerTests.cs index a989ae25fe8..c2d1bbd611f 100644 --- a/test/OrchardCore.Tests/OrchardCore.Environment.Cache/CacheScopeManagerTests.cs +++ b/test/OrchardCore.Tests/OrchardCore.Environment.Cache/CacheScopeManagerTests.cs @@ -67,7 +67,7 @@ public void ContextsAreBubbledUp2() Assert.Collection(scopeA.Contexts, context => Assert.Contains("1", context), context => Assert.Contains("2", context)); - Assert.False(scopeB.Contexts.Any()); + Assert.Empty(scopeB.Contexts); } [Fact] diff --git a/test/OrchardCore.Tests/Shell/ShellContainerFactoryTests.cs b/test/OrchardCore.Tests/Shell/ShellContainerFactoryTests.cs index 1f4f978d09f..3b8c6f93484 100644 --- a/test/OrchardCore.Tests/Shell/ShellContainerFactoryTests.cs +++ b/test/OrchardCore.Tests/Shell/ShellContainerFactoryTests.cs @@ -15,7 +15,7 @@ public class ShellContainerFactoryTests .AsDefaultShell() .AsUninitialized(); - private readonly IShellContainerFactory _shellContainerFactory; + private readonly ShellContainerFactory _shellContainerFactory; private readonly IServiceProvider _applicationServiceProvider; public ShellContainerFactoryTests() diff --git a/test/OrchardCore.Tests/Stubs/StubPoFileLocationProvider.cs b/test/OrchardCore.Tests/Stubs/StubPoFileLocationProvider.cs index 637565fbc58..58c4b3534af 100644 --- a/test/OrchardCore.Tests/Stubs/StubPoFileLocationProvider.cs +++ b/test/OrchardCore.Tests/Stubs/StubPoFileLocationProvider.cs @@ -4,7 +4,7 @@ namespace OrchardCore.Tests { public class StubPoFileLocationProvider : ILocalizationFileLocationProvider { - private readonly IFileProvider _fileProvider; + private readonly PhysicalFileProvider _fileProvider; private readonly string _resourcesContainer; public StubPoFileLocationProvider(IHostEnvironment hostingEnvironment, IOptions localizationOptions) diff --git a/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs b/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs index 875bac0f53a..07a21797490 100644 --- a/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs +++ b/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs @@ -69,7 +69,7 @@ public async Task CanExecuteSimpleWorkflow() Assert.Equal(expectedSum, (double)workflowExecutionContext.Output["Sum"]); } - private static IServiceProvider CreateServiceProvider() + private static ServiceProvider CreateServiceProvider() { var services = new ServiceCollection(); services.AddScoped(typeof(Resolver<>)); @@ -80,7 +80,7 @@ private static IServiceProvider CreateServiceProvider() return services.BuildServiceProvider(); } - private static IWorkflowScriptEvaluator CreateWorkflowScriptEvaluator(IServiceProvider serviceProvider) + private static JavaScriptWorkflowScriptEvaluator CreateWorkflowScriptEvaluator(IServiceProvider serviceProvider) { var memoryCache = new MemoryCache(new MemoryCacheOptions()); var javaScriptEngine = new JavaScriptEngine(memoryCache); From bf7e00f1617861d24367cb5b64e9228139c0341a Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Mon, 8 Apr 2024 09:13:05 +0300 Subject: [PATCH 2/2] Use separate using for System --- .../OrchardCore.Alias/Handlers/AliasPartHandler.cs | 3 ++- .../GraphQL/Types/HtmlFieldQueryObjectType.cs | 5 +++-- .../Sitemaps/LocalizedContentItemsQueryProvider.cs | 9 +++++---- .../Handlers/PreviewPartHandler.cs | 3 ++- .../Drivers/AuditTrailPartSettingsDisplayDriver.cs | 5 +++-- .../Services/ContentItemIdHandleProvider.cs | 3 ++- .../Sitemaps/ContentTypesSitemapSourceBuilder.cs | 5 +++-- .../Sitemaps/ContentTypesSitemapSourceDriver.cs | 13 +++++++------ .../ContentTypesSitemapSourceUpdateHandler.cs | 5 +++-- .../Sitemaps/DefaultContentItemsQueryProvider.cs | 5 +++-- .../Configuration/FacebookLoginConfiguration.cs | 3 ++- .../Configuration/GithubOptionsConfiguration.cs | 3 ++- .../Configuration/GoogleOptionsConfiguration.cs | 3 ++- .../GraphQL/HtmlBodyQueryObjectType.cs | 3 ++- .../Handlers/HtmlBodyPartHandler.cs | 3 ++- .../GraphQL/MarkdownBodyQueryObjectType.cs | 3 ++- .../GraphQL/MarkdownFieldQueryObjectType.cs | 5 +++-- .../Handlers/MarkdownBodyPartHandler.cs | 3 ++- .../Configuration/AzureADOptionsConfiguration.cs | 5 +++-- .../MicrosoftAccountOptionsConfiguration.cs | 3 ++- .../Controllers/UserInfoController.cs | 3 ++- .../OrchardCore.Roles/Services/RoleUpdater.cs | 9 +++++---- ...ContentPickerFieldElasticEditorSettingsDriver.cs | 3 ++- .../ContentPickerFieldLuceneEditorSettingsDriver.cs | 3 ++- .../Handlers/SitemapIndexTypeUpdateHandler.cs | 5 +++-- .../OrchardCore.Title/Handlers/TitlePartHandler.cs | 3 ++- .../OrchardCore.Widgets/ContentCardShapes.cs | 5 +++-- .../Services/LocalizedStringComparer.cs | 3 ++- .../Services/AutorouteHandleProvider.cs | 3 ++- .../ContentPartFieldDefinitionDisplayDriver.cs | 3 ++- .../ContentTypePartDefinitionDisplayDriver.cs | 3 ++- .../Descriptors/PlacementInfo.cs | 3 ++- .../ContentFieldIndexHandler.cs | 5 +++-- .../Providers/ElasticContentPickerResultProvider.cs | 3 ++- 34 files changed, 89 insertions(+), 55 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs index d3e5ca053b2..e3cf7c4210c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Alias/Handlers/AliasPartHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -124,7 +125,7 @@ public override async Task CloningAsync(CloneContentContext context, AliasPart p private async Task GetPatternAsync(AliasPart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AliasPart), System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(AliasPart), StringComparison.Ordinal)); var pattern = contentTypePartDefinition.GetSettings().Pattern; return pattern; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs index 395b3128e87..b9c6bc98910 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/GraphQL/Types/HtmlFieldQueryObjectType.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -45,8 +46,8 @@ private static async ValueTask RenderHtml(IResolveFieldContext string.Equals(x.Name, partName, System.StringComparison.Ordinal)); - var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, System.StringComparison.Ordinal)); + var contentPartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.Name, partName, StringComparison.Ordinal)); + var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, StringComparison.Ordinal)); var settings = contentPartFieldDefinition.GetSettings(); var html = ctx.Source.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs index 7645c7cf811..3d8488c96a0 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Sitemaps/LocalizedContentItemsQueryProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentLocalization.Models; @@ -54,14 +55,14 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content type is still valid to include in sitemap. var contentType = routeableContentTypeDefinitions - .FirstOrDefault(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); + .FirstOrDefault(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, StringComparison.Ordinal)); if (contentType == null) { return; } - if (contentType.Parts.Any(ctd => string.Equals(ctd.Name, nameof(LocalizationPart), System.StringComparison.Ordinal))) + if (contentType.Parts.Any(ctd => string.Equals(ctd.Name, nameof(LocalizationPart), StringComparison.Ordinal))) { // Get all content items here for reference. Then reduce by default culture. // We know that the content item should be localized. @@ -77,7 +78,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content // Reduce by default culture. var items = queryResults - .Where(ci => string.Equals(ci.As().Culture, defaultCulture, System.StringComparison.Ordinal)) + .Where(ci => string.Equals(ci.As().Culture, defaultCulture, StringComparison.Ordinal)) .Skip(source.LimitedContentType.Skip) .Take(source.LimitedContentType.Take); @@ -104,7 +105,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content types are still valid to include in sitemap. var typesToIndex = routeableContentTypeDefinitions - .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, System.StringComparison.Ordinal))) + .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, StringComparison.Ordinal))) .Select(x => x.Name); // No advantage here in reducing with localized index. diff --git a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs index 212f3c77571..2a38eecd141 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Handlers/PreviewPartHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -31,7 +32,7 @@ public PreviewPartHandler( private async Task GetPatternAsync(PreviewPart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "PreviewPart", System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "PreviewPart", StringComparison.Ordinal)); var pattern = contentTypePartDefinition.GetSettings().Pattern; return pattern; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs index 9045a2a9ed6..069516f1af1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AuditTrail/Drivers/AuditTrailPartSettingsDisplayDriver.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Contents.AuditTrail.Models; @@ -13,7 +14,7 @@ public class AuditTrailPartSettingsDisplayDriver : ContentTypePartDefinitionDisp { public override IDisplayResult Edit(ContentTypePartDefinition model, IUpdateModel updater) { - if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, System.StringComparison.Ordinal)) + if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, StringComparison.Ordinal)) { return null; } @@ -27,7 +28,7 @@ public override IDisplayResult Edit(ContentTypePartDefinition model, IUpdateMode public override async Task UpdateAsync(ContentTypePartDefinition model, UpdateTypePartEditorContext context) { - if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, System.StringComparison.Ordinal)) + if (!string.Equals(nameof(AuditTrailPart), model.PartDefinition.Name, StringComparison.Ordinal)) { return null; } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Services/ContentItemIdHandleProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Services/ContentItemIdHandleProvider.cs index ac9d81b1f9e..9aae77e36cd 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Services/ContentItemIdHandleProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Services/ContentItemIdHandleProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using OrchardCore.ContentManagement; @@ -9,7 +10,7 @@ public class ContentItemIdHandleProvider : IContentHandleProvider public Task GetContentItemIdAsync(string handle) { - if (handle.StartsWith("contentitemid:", System.StringComparison.OrdinalIgnoreCase)) + if (handle.StartsWith("contentitemid:", StringComparison.OrdinalIgnoreCase)) { var contentItemId = handle[14..]; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs index b5d6a7e9c42..3f2fef1690e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceBuilder.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -118,7 +119,7 @@ private async Task PopulateChangeFrequencyPriority(ContentTypesSitemapSource sou else { var sitemapEntry = source.ContentTypes - .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, System.StringComparison.Ordinal)); + .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, StringComparison.Ordinal)); changeFrequencyValue = sitemapEntry.ChangeFrequency.ToString(); } @@ -138,7 +139,7 @@ private async Task PopulateChangeFrequencyPriority(ContentTypesSitemapSource sou else { var sitemapEntry = source.ContentTypes - .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, System.StringComparison.Ordinal)); + .FirstOrDefault(ct => string.Equals(ct.ContentTypeName, contentItem.ContentType, StringComparison.Ordinal)); priorityIntValue = sitemapEntry.Priority; } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs index 0453b0117ce..6beff7bf168 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceDriver.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using OrchardCore.DisplayManagement.Handlers; @@ -36,9 +37,9 @@ public override async Task EditAsync(ContentTypesSitemapSource s { ContentTypeName = ctd.Name, ContentTypeDisplayName = ctd.DisplayName, - IsChecked = sitemapSource.ContentTypes.Any(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)), - ChangeFrequency = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal))?.ChangeFrequency ?? ChangeFrequency.Daily, - Priority = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, System.StringComparison.Ordinal))?.Priority ?? 5, + IsChecked = sitemapSource.ContentTypes.Any(s => string.Equals(s.ContentTypeName, ctd.Name, StringComparison.Ordinal)), + ChangeFrequency = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, StringComparison.Ordinal))?.ChangeFrequency ?? ChangeFrequency.Daily, + Priority = sitemapSource.ContentTypes.FirstOrDefault(s => string.Equals(s.ContentTypeName, ctd.Name, StringComparison.Ordinal))?.Priority ?? 5, }) .OrderBy(ctd => ctd.ContentTypeDisplayName) .ToArray(); @@ -53,11 +54,11 @@ public override async Task EditAsync(ContentTypesSitemapSource s .ToArray(); var limitedCtd = contentTypeDefinitions - .FirstOrDefault(ctd => string.Equals(sitemapSource.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); + .FirstOrDefault(ctd => string.Equals(sitemapSource.LimitedContentType.ContentTypeName, ctd.Name, StringComparison.Ordinal)); if (limitedCtd != null) { - var limitedEntry = limitedEntries.FirstOrDefault(le => string.Equals(le.ContentTypeName, limitedCtd.Name, System.StringComparison.Ordinal)); + var limitedEntry = limitedEntries.FirstOrDefault(le => string.Equals(le.ContentTypeName, limitedCtd.Name, StringComparison.Ordinal)); limitedEntry.Priority = sitemapSource.LimitedContentType.Priority; limitedEntry.ChangeFrequency = sitemapSource.LimitedContentType.ChangeFrequency; limitedEntry.Skip = sitemapSource.LimitedContentType.Skip; @@ -106,7 +107,7 @@ public override async Task UpdateAsync(ContentTypesSitemapSource }) .ToArray(); - var limitedEntry = model.LimitedContentTypes.FirstOrDefault(lct => string.Equals(lct.ContentTypeName, model.LimitedContentType, System.StringComparison.Ordinal)); + var limitedEntry = model.LimitedContentTypes.FirstOrDefault(lct => string.Equals(lct.ContentTypeName, model.LimitedContentType, StringComparison.Ordinal)); if (limitedEntry != null) { sitemap.LimitedContentType.ContentTypeName = limitedEntry.ContentTypeName; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs index a45ded27224..488f2399df4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/ContentTypesSitemapSourceUpdateHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentManagement; @@ -51,12 +52,12 @@ public async Task UpdateSitemapAsync(SitemapUpdateContext context) sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, System.StringComparison.Ordinal)) + else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, StringComparison.Ordinal)) { sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, System.StringComparison.Ordinal))) + else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, StringComparison.Ordinal))) { sitemap.Identifier = IdGenerator.GenerateId(); break; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs index 049afdcf61a..26b2d7ce850 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Sitemaps/DefaultContentItemsQueryProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentManagement; @@ -43,7 +44,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content type is still valid to include in sitemap. var typeIsValid = routeableContentTypeDefinitions - .Any(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, System.StringComparison.Ordinal)); + .Any(ctd => string.Equals(source.LimitedContentType.ContentTypeName, ctd.Name, StringComparison.Ordinal)); if (typeIsValid) { @@ -61,7 +62,7 @@ public async Task GetContentItemsAsync(ContentTypesSitemapSource source, Content { // Test that content types are still valid to include in sitemap. var typesToIndex = routeableContentTypeDefinitions - .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, System.StringComparison.Ordinal))) + .Where(ctd => source.ContentTypes.Any(s => string.Equals(ctd.Name, s.ContentTypeName, StringComparison.Ordinal))) .Select(x => x.Name); var queryResults = await _session.Query() diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs index 6c703777265..d400a12d7c6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Configuration/FacebookLoginConfiguration.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; using System.Diagnostics; using System.Linq; @@ -67,7 +68,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, FacebookOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, FacebookDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) + if (!string.Equals(name, FacebookDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs index 88c951467d3..46b38f58352 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Configuration/GithubOptionsConfiguration.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.DataProtection; @@ -51,7 +52,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, GitHubOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, GitHubDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) + if (!string.Equals(name, GitHubDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs index 458bbd27ad3..47d81ecd7f7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/Authentication/Configuration/GoogleOptionsConfiguration.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Google; @@ -50,7 +51,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, GoogleOptions options) { - if (!string.Equals(name, GoogleDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) + if (!string.Equals(name, GoogleDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs index 850ece5ab76..d5fe4dbf428 100644 --- a/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Html/GraphQL/HtmlBodyQueryObjectType.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -36,7 +37,7 @@ private static async ValueTask RenderHtml(IResolveFieldContext(); var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(ctx.Source.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); var html = ctx.Source.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs index e1d5ba93b01..9783099a6cb 100644 --- a/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Html/Handlers/HtmlBodyPartHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -41,7 +42,7 @@ public override Task GetContentItemAspectAsync(ContentItemAspectContext context, try { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "HtmlBodyPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); var html = part.Html; diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs index 1f373225dba..7d1c0547ac7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownBodyQueryObjectType.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -47,7 +48,7 @@ private static async ValueTask ToHtml(IResolveFieldContext(); var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(ctx.Source.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); // The default Markdown option is to entity escape html diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs index 2ac6e5c3c2c..3248878322d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/GraphQL/MarkdownFieldQueryObjectType.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -56,8 +57,8 @@ private static async ValueTask ToHtml(IResolveFieldContext string.Equals(x.Name, partName, System.StringComparison.Ordinal)); - var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, System.StringComparison.Ordinal)); + var contentPartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.Name, partName, StringComparison.Ordinal)); + var contentPartFieldDefinition = contentPartDefinition.PartDefinition.Fields.FirstOrDefault(x => string.Equals(x.Name, fieldName, StringComparison.Ordinal)); var settings = contentPartFieldDefinition.GetSettings(); diff --git a/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs index 31f2c6ccacd..fb896d144bc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Markdown/Handlers/MarkdownBodyPartHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; @@ -49,7 +50,7 @@ public override Task GetContentItemAspectAsync(ContentItemAspectContext context, try { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, "MarkdownBodyPart", StringComparison.Ordinal)); var settings = contentTypePartDefinition.GetSettings(); // The default Markdown option is to entity escape html diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs index bbbbbfedbe6..186228b421d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/AzureADOptionsConfiguration.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OpenIdConnect; @@ -56,7 +57,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, MicrosoftIdentityOptions options) { - if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, System.StringComparison.Ordinal)) + if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, StringComparison.Ordinal)) { return; } @@ -81,7 +82,7 @@ public void Configure(string name, MicrosoftIdentityOptions options) public void Configure(string name, PolicySchemeOptions options) { - if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, System.StringComparison.Ordinal)) + if (!string.Equals(name, MicrosoftIdentityDefaults.AzureAd, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs index 3b2fb3f83c3..afa7b295b10 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Configuration/MicrosoftAccountOptionsConfiguration.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; @@ -52,7 +53,7 @@ public void Configure(AuthenticationOptions options) public void Configure(string name, MicrosoftAccountOptions options) { // Ignore OpenID Connect client handler instances that don't correspond to the instance managed by the OpenID module. - if (!string.Equals(name, MicrosoftAccountDefaults.AuthenticationScheme, System.StringComparison.Ordinal)) + if (!string.Equals(name, MicrosoftAccountDefaults.AuthenticationScheme, StringComparison.Ordinal)) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs index 201621e04e0..af7a118ef9c 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Controllers/UserInfoController.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -47,7 +48,7 @@ public async Task Me() // Ensure the access token represents a user and not an application. var type = principal.FindFirst(OpenIdConstants.Claims.EntityType)?.Value; - if (!string.Equals(type, OpenIdConstants.EntityTypes.User, System.StringComparison.Ordinal)) + if (!string.Equals(type, OpenIdConstants.EntityTypes.User, StringComparison.Ordinal)) { return Forbid(new AuthenticationProperties(new Dictionary { diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleUpdater.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleUpdater.cs index fcdb5c85455..3651293739c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleUpdater.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleUpdater.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -67,7 +68,7 @@ private async Task UpdateRolesForInstalledFeatureAsync(IFeatureInfo feature) var stereotypes = provider.GetDefaultStereotypes(); foreach (var stereotype in stereotypes) { - var role = rolesDocument.Roles.FirstOrDefault(role => string.Equals(role.RoleName, stereotype.Name, System.StringComparison.OrdinalIgnoreCase)); + var role = rolesDocument.Roles.FirstOrDefault(role => string.Equals(role.RoleName, stereotype.Name, StringComparison.OrdinalIgnoreCase)); if (role == null) { continue; @@ -129,7 +130,7 @@ private async Task UpdateRolesForEnabledFeatureAsync(IFeatureInfo feature) private async Task UpdateRoleForInstalledFeaturesAsync(string roleName) { var rolesDocument = await _documentManager.GetOrCreateMutableAsync(); - var role = rolesDocument.Roles.FirstOrDefault(role => string.Equals(role.RoleName, roleName, System.StringComparison.OrdinalIgnoreCase)); + var role = rolesDocument.Roles.FirstOrDefault(role => string.Equals(role.RoleName, roleName, StringComparison.OrdinalIgnoreCase)); if (role == null) { return; @@ -151,7 +152,7 @@ private async Task UpdateRoleForInstalledFeaturesAsync(string roleName) var stereotypes = _permissionProviders .SelectMany(provider => provider.GetDefaultStereotypes()) - .Where(stereotype => string.Equals(stereotype.Name, roleName, System.StringComparison.OrdinalIgnoreCase)); + .Where(stereotype => string.Equals(stereotype.Name, roleName, StringComparison.OrdinalIgnoreCase)); if (!stereotypes.Any()) { @@ -179,7 +180,7 @@ private static bool UpdateRolesForEnabledFeature(Role role, IEnumerable provider.GetDefaultStereotypes()) - .Where(stereotype => string.Equals(stereotype.Name, role.RoleName, System.StringComparison.OrdinalIgnoreCase)); + .Where(stereotype => string.Equals(stereotype.Name, role.RoleName, StringComparison.OrdinalIgnoreCase)); if (!stereotypes.Any()) { diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs index 53af2595d4b..6a794e43e53 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Text.Json.Nodes; using System.Threading.Tasks; @@ -48,7 +49,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals("ContentPickerField", model.FieldDefinition.Name, System.StringComparison.Ordinal); + return string.Equals("ContentPickerField", model.FieldDefinition.Name, StringComparison.Ordinal); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs index 5f273b15e99..0e0035fd64b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Text.Json.Nodes; using System.Threading.Tasks; @@ -44,7 +45,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals("ContentPickerField", model.FieldDefinition.Name, System.StringComparison.Ordinal); + return string.Equals("ContentPickerField", model.FieldDefinition.Name, StringComparison.Ordinal); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs index feccd40b20c..235febbd27f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Handlers/SitemapIndexTypeUpdateHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentManagement; @@ -52,12 +53,12 @@ public async Task UpdateSitemapAsync(SitemapUpdateContext context) sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, System.StringComparison.Ordinal)) + else if (source.LimitItems && string.Equals(source.LimitedContentType.ContentTypeName, contentTypeName, StringComparison.Ordinal)) { sitemap.Identifier = IdGenerator.GenerateId(); break; } - else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, System.StringComparison.Ordinal))) + else if (source.ContentTypes.Any(ct => string.Equals(ct.ContentTypeName, contentTypeName, StringComparison.Ordinal))) { sitemap.Identifier = IdGenerator.GenerateId(); break; diff --git a/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs b/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs index c6c43ea0776..9f1fb26cd3e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Title/Handlers/TitlePartHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -102,7 +103,7 @@ private async Task SetTitleAsync(TitlePart part) private async Task GetSettingsAsync(TitlePart part) { var contentTypeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(part.ContentItem.ContentType); - var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(TitlePart), System.StringComparison.Ordinal)); + var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => string.Equals(x.PartDefinition.Name, nameof(TitlePart), StringComparison.Ordinal)); return contentTypePartDefinition.GetSettings(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs b/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs index b4384e3c0c5..d3b09a8b3b9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs +++ b/src/OrchardCore.Modules/OrchardCore.Widgets/ContentCardShapes.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.Descriptors; @@ -60,7 +61,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) // ContentCard_Edit__LandingPage__BagPart__Service, ContentCard_Edit__Form__FlowPart__Label contentCardEditor.Metadata.Alternates.Add($"{ContentCardEdit}__{parentContentType}__{collectionType}__{contentType}"); - if (!string.IsNullOrWhiteSpace(namedPart) && !(namedPart.Equals(collectionType, System.StringComparison.Ordinal))) + if (!string.IsNullOrWhiteSpace(namedPart) && !(namedPart.Equals(collectionType, StringComparison.Ordinal))) { // Define edit card shape for selected child with specific type and partname per parent content type // ContentCard_Edit__[ParentContentType]__[PartName] @@ -118,7 +119,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) // e.g. ContentCard_Frame__Page__FlowPart__Container, ContentCard_Frame__LandingPage__BagPart__Service, ContentCard_Frame__Form__FlowPart__Label contentCardFrame.Metadata.Alternates.Add($"{ContentCardFrame}__{parentContentType}__{collectionType}__{contentType}"); - if (!string.IsNullOrWhiteSpace(namedPart) && !namedPart.Equals(collectionType, System.StringComparison.Ordinal)) + if (!string.IsNullOrWhiteSpace(namedPart) && !namedPart.Equals(collectionType, StringComparison.Ordinal)) { // Define frame card shape for child with specific partname and parent content type // ContentCard_Frame__[ParentContentType]__[PartName] diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs index fcc025bae87..afdcc74f027 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/LocalizedStringComparer.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Microsoft.Extensions.Localization; @@ -7,7 +8,7 @@ public class LocalizedStringComparer : IEqualityComparer { public bool Equals(LocalizedString x, LocalizedString y) { - return x.Name.Equals(y.Name, System.StringComparison.Ordinal); + return x.Name.Equals(y.Name, StringComparison.Ordinal); } public int GetHashCode(LocalizedString obj) diff --git a/src/OrchardCore/OrchardCore.Autoroute.Core/Services/AutorouteHandleProvider.cs b/src/OrchardCore/OrchardCore.Autoroute.Core/Services/AutorouteHandleProvider.cs index 3d7f444c165..eb6a34b5f15 100644 --- a/src/OrchardCore/OrchardCore.Autoroute.Core/Services/AutorouteHandleProvider.cs +++ b/src/OrchardCore/OrchardCore.Autoroute.Core/Services/AutorouteHandleProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Routing; @@ -14,7 +15,7 @@ public class AutorouteHandleProvider : IContentHandleProvider public async Task GetContentItemIdAsync(string handle) { - if (handle.StartsWith("slug:", System.StringComparison.OrdinalIgnoreCase)) + if (handle.StartsWith("slug:", StringComparison.OrdinalIgnoreCase)) { handle = handle[5..]; diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs index 1a95b671d6a..e3ae2f781ed 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentPartFieldDefinitionDisplayDriver.cs @@ -1,3 +1,4 @@ +using System; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.Handlers; @@ -37,7 +38,7 @@ public abstract class ContentPartFieldDefinitionDisplayDriver : ContentP { public override bool CanHandleModel(ContentPartFieldDefinition model) { - return string.Equals(typeof(TField).Name, model.FieldDefinition.Name, System.StringComparison.Ordinal); + return string.Equals(typeof(TField).Name, model.FieldDefinition.Name, StringComparison.Ordinal); } } } diff --git a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs index 2dadb8b6d0f..ae760f9e36e 100644 --- a/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs +++ b/src/OrchardCore/OrchardCore.ContentTypes.Abstractions/Editors/ContentTypePartDefinitionDisplayDriver.cs @@ -1,3 +1,4 @@ +using System; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.Handlers; @@ -33,7 +34,7 @@ public abstract class ContentTypePartDefinitionDisplayDriver : ContentTyp { public override bool CanHandleModel(ContentTypePartDefinition model) { - return string.Equals(typeof(TPart).Name, model.PartDefinition.Name, System.StringComparison.Ordinal); + return string.Equals(typeof(TPart).Name, model.PartDefinition.Name, StringComparison.Ordinal); } } } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/PlacementInfo.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/PlacementInfo.cs index 6e95d9c9a4f..344d3a08778 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/PlacementInfo.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Descriptors/PlacementInfo.cs @@ -1,3 +1,4 @@ +using System; using OrchardCore.DisplayManagement.Shapes; namespace OrchardCore.DisplayManagement.Descriptors @@ -15,7 +16,7 @@ public class PlacementInfo public bool IsLayoutZone() { - return Location.StartsWith("/", System.StringComparison.OrdinalIgnoreCase); + return Location.StartsWith("/", StringComparison.OrdinalIgnoreCase); } /// diff --git a/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs b/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs index 320cbee0e7e..582230ab4ff 100644 --- a/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs +++ b/src/OrchardCore/OrchardCore.Indexing.Abstractions/ContentFieldIndexHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using OrchardCore.ContentManagement; @@ -13,8 +14,8 @@ public abstract class ContentFieldIndexHandler : IContentFieldIndexHandl { Task IContentFieldIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildIndexContext context, IContentIndexSettings settings) { - if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, System.StringComparison.Ordinal) && - !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, System.StringComparison.Ordinal)) + if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal) && + !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name, StringComparison.Ordinal)) { return Task.CompletedTask; } diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs index e55e79d9a67..42310d7ec50 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Providers/ElasticContentPickerResultProvider.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -108,7 +109,7 @@ await _elasticIndexManager.SearchAsync(indexName, async elasticClient => { ContentItemId = doc["ContentItemId"].ToString(), DisplayText = doc["Content.ContentItem.DisplayText.keyword"].ToString(), - HasPublished = doc["Content.ContentItem.Published"].ToString().ToLowerInvariant().Equals("true", System.StringComparison.Ordinal) + HasPublished = doc["Content.ContentItem.Published"].ToString().ToLowerInvariant().Equals("true", StringComparison.Ordinal) }); } }