Skip to content

Commit

Permalink
IDE0300 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed Jun 7, 2024
1 parent 6911193 commit 06b0848
Show file tree
Hide file tree
Showing 42 changed files with 63 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ indent_size = 4
indent_size = 2

[*.cs]
dotnet_diagnostic.IDE0300.severity = suggestion
dotnet_style_prefer_collection_expression = true
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true : suggestion
csharp_style_var_when_type_is_apparent = true : suggestion
Expand Down
1 change: 1 addition & 0 deletions src/OrchardCore.Build/OrchardCore.Commons.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>

<!-- Common NuGet properties-->
<OCFrameworkDescription>Orchard Core Framework is an application framework for building modular, multi-tenant applications on ASP.NET Core.</OCFrameworkDescription>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ public override async Task CreatingAsync(CreateContentContext context, Localizat
{
if (string.IsNullOrEmpty(part.LocalizationSet))
{
context.ContentItem.Alter<LocalizationPart>(p =>
context.ContentItem.Alter<LocalizationPart>(p =>
p.LocalizationSet = _idGenerator.GenerateUniqueId()
);
}

if (string.IsNullOrEmpty(part.Culture))
{
await context.ContentItem.AlterAsync<LocalizationPart>(async p =>
await context.ContentItem.AlterAsync<LocalizationPart>(async p =>
p.Culture = await _localizationService.GetDefaultCultureAsync()
);
}
}

public override Task GetContentItemAspectAsync(ContentItemAspectContext context, LocalizationPart part)
{
return context.ForAsync<CultureAspect>(cultureAspect =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace OrchardCore.ContentTypes.Editors
public class ContentTypeSettingsDisplayDriver : ContentTypeDefinitionDisplayDriver
{
private static readonly ContentTypeDefinitionDriverOptions _defaultOptions = new();
private readonly IStereotypeService _stereotypeService;
private readonly IStereotypeService _stereotypeService;
private readonly ContentTypeDefinitionOptions _options;

protected readonly IStringLocalizer S;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecuti
{
workflowContext.CorrelationId = contentItem.ContentItemId;
}

workflowContext.Properties[ContentEventConstants.ContentItemInputKey] = contentItem;
workflowContext.LastResult = contentItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecuti
{
workflowContext.CorrelationId = contentItem.ContentItemId;
}

workflowContext.Properties[ContentEventConstants.ContentItemInputKey] = contentItem;
workflowContext.LastResult = contentItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task<ActionResult> IndexPOST()
AllowedOrigins = settingViewModel.AllowedOrigins,
IsDefaultPolicy = settingViewModel.IsDefaultPolicy
});

if (settingViewModel.AllowAnyOrigin && settingViewModel.AllowCredentials)
{
policyWarnings.Add(settingViewModel.Name);
Expand All @@ -134,7 +134,7 @@ public async Task<ActionResult> IndexPOST()

if (policyWarnings.Count > 0)
{
await _notifier.WarningAsync(H["Specifying {0} and {1} is an insecure configuration and can result in cross-site request forgery. The CORS service returns an invalid CORS response when an app is configured with both methods.<br /><strong>Affected policies: {2} </strong><br />Refer to docs:<a href='https://learn.microsoft.com/en-us/aspnet/core/security/cors' target='_blank'>https://learn.microsoft.com/en-us/aspnet/core/security/cors</a>", "AllowAnyOrigin", "AllowCredentias", string.Join(", ", policyWarnings) ]);
await _notifier.WarningAsync(H["Specifying {0} and {1} is an insecure configuration and can result in cross-site request forgery. The CORS service returns an invalid CORS response when an app is configured with both methods.<br /><strong>Affected policies: {2} </strong><br />Refer to docs:<a href='https://learn.microsoft.com/en-us/aspnet/core/security/cors' target='_blank'>https://learn.microsoft.com/en-us/aspnet/core/security/cors</a>", "AllowAnyOrigin", "AllowCredentias", string.Join(", ", policyWarnings)]);
}

return View(model);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OrchardCore.Email.Azure.Models;
namespace OrchardCore.Email.Azure.Models;

public class DefaultAzureEmailOptions : AzureEmailOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace OrchardCore.Email.ViewModels;
namespace OrchardCore.Email.ViewModels;

public class EmailSettingsBaseViewModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<IActionResult> Options()
{
return Forbid();
}

if (_options.Validate().Any())
{
await _notifier.ErrorAsync(H["The Amazon S3 Media feature is enabled, but it was not configured with appsettings.json."]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.AspNetCore.Http;

namespace OrchardCore.Media.Services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static FieldType BuildSchemaBasedFieldType(SqlQuery query, JsonNode quer
return source[context.FieldDefinition.Metadata["Name"].ToString()].ToObject<int>();
}),
};

field.Metadata.Add("Name", name);
typetype.AddField(field);
}
Expand All @@ -159,9 +159,9 @@ async ValueTask<object> ResolveAsync(IResolveFieldContext<object> context)

var parameters = context.GetArgument<string>("parameters");

var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];
var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];

var result = await queryManager.ExecuteQueryAsync(iquery, queryParameters);

Expand Down Expand Up @@ -199,9 +199,9 @@ async ValueTask<object> ResolveAsync(IResolveFieldContext<object> context)

var parameters = context.GetArgument<string>("parameters");

var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];
var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];

var result = await queryManager.ExecuteQueryAsync(iquery, queryParameters);
return result.Items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ async ValueTask<object> ResolveAsync(IResolveFieldContext<object> context)

var parameters = context.GetArgument<string>("parameters");

var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];
var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];

var result = await queryManager.ExecuteQueryAsync(iquery, queryParameters);

Expand Down Expand Up @@ -200,9 +200,9 @@ async ValueTask<object> ResolveAsync(IResolveFieldContext<object> context)

var parameters = context.GetArgument<string>("parameters");

var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];
var queryParameters = parameters != null ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];

var result = await queryManager.ExecuteQueryAsync(iquery, queryParameters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task BuildAsync(ISchema schema)

private static FieldType BuildSchemaBasedFieldType(LuceneQuery query, JsonNode querySchema, string fieldTypeName)
{
var properties = querySchema["properties"]?.AsObject();
var properties = querySchema["properties"]?.AsObject();
if (properties == null)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private async Task<SignInResult> ExternalLoginSignInAsync(IUser user, ExternalLo
var userInfo = user as User;

var context = new UpdateUserContext(user, info.LoginProvider, externalClaims, userInfo.Properties)
{
{
UserClaims = userInfo.UserClaims,
UserRoles = userRoles,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public override async Task<IDisplayResult> UpdateAsync(User user, UpdateEditorCo
await context.Updater.TryUpdateModelAsync(model, Prefix);


var roles = await GetRoleAsync();
var roles = await GetRoleAsync();
// Authorize each role in the model to prevent html injection.
var accessibleRoleNames = await GetAccessibleRoleNamesAsync(roles);
var currentUserRoleNames = await _userRoleStore.GetRolesAsync(user, default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<string> GenerateUserName(string provider, IEnumerable<Serializ
public async Task UpdateUserAsync(UpdateUserContext context)
{
var loginSettings = await _siteService.GetSettingsAsync<LoginSettings>();

UpdateUserInternal(context, loginSettings);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using OrchardCore.Users.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task ProcessDeploymentStepAsync(DeploymentStep step, DeploymentPlan
public static void ProcessWorkflowType(DeploymentPlanResult result, IEnumerable<WorkflowType> workflowTypes, JsonSerializerOptions jsonSerializerOptions)
{
var data = new JsonArray();

foreach (var workflowType in workflowTypes)
{
var objectData = JObject.FromObject(workflowType, jsonSerializerOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public HttpMethodsProvider(IHttpContextAccessor httpContextAccessor)
_responseWriteMethod = new GlobalMethod
{
Name = "responseWrite",
Method = serviceProvider => (Action<string>)(text => {
Method = serviceProvider => (Action<string>)(text =>
{
httpContextAccessor.HttpContext.Items[WorkflowHttpResult.Instance] = WorkflowHttpResult.Instance;
httpContextAccessor.HttpContext.Response.WriteAsync(text).GetAwaiter().GetResult();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static Task ExecuteAfterEndOfRequestAsync(string jobName, Func<ShellScope
httpContextAccessor.HttpContext = shellContext.CreateHttpContext();
// Restore the current user.
httpContextAccessor.HttpContext.User = userPrincipal;
// Here the 'IActionContextAccessor.ActionContext' need to be cleared, this 'AsyncLocal'
// field is not cleared by 'AspnetCore' and still references the previous 'HttpContext'.
var actionContextAccessor = scope.ServiceProvider.GetService<IActionContextAccessor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void SetValue(int index, object? value)
}
}

IEnumerator<JsonNode?> IEnumerable<JsonNode?>.GetEnumerator()
IEnumerator<JsonNode?> IEnumerable<JsonNode?>.GetEnumerator()
=> _jsonArray.AsEnumerable().GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
Expand Down
4 changes: 2 additions & 2 deletions src/OrchardCore/OrchardCore.Abstractions/Json/Nodes/JNode.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Json.Path;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json.Settings;
using System.Threading;
using System.Threading.Tasks;
using Json.Path;

#nullable enable

Expand Down Expand Up @@ -187,7 +187,7 @@ jsonNode is JsonObject jsonObject && jsonObject.Count > 0 ||
ArgumentNullException.ThrowIfNull(path);

path = path.Trim();
if (string.IsNullOrEmpty(path))
if (string.IsNullOrEmpty(path))
{
return jsonNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class RequireFeaturesAttribute : Attribute
{
public RequireFeaturesAttribute(string featureName)
{
RequiredFeatureNames = new string[] { featureName };
RequiredFeatureNames = [featureName];
}

public RequireFeaturesAttribute(string featureName, params string[] otherFeatureNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Task<IDictionary<string, string>> ToConfigurationDataAsync(this Js
{
if (jConfiguration is null)
{
return Task.FromResult< IDictionary<string, string>>(new Dictionary<string, string>());
return Task.FromResult<IDictionary<string, string>>(new Dictionary<string, string>());
}

var configurationString = jConfiguration.ToJsonString(JOptions.Default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static async Task EnableFeaturesAsync(this IShellFeaturesManager shellFea
{
ArgumentNullException.ThrowIfNull(featureIds);

if (featureIds.Length == 0)
if (featureIds.Length == 0)
{
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public static string GetConnectionString(SqliteOptions sqliteOptions, string dat
public static string GetDatabaseFolder(ShellOptions shellOptions, string shellName) =>
Path.Combine(shellOptions.ShellsApplicationDataPath, shellOptions.ShellsContainerName, shellName);

private static SqliteConnectionStringBuilder GetSqliteConnectionStringBuilder(SqliteOptions sqliteOptions, string databaseFolder, string databaseName, SqliteOpenMode sqliteOpenMode){
private static SqliteConnectionStringBuilder GetSqliteConnectionStringBuilder(SqliteOptions sqliteOptions, string databaseFolder, string databaseName, SqliteOpenMode sqliteOpenMode)
{
return new SqliteConnectionStringBuilder
{
DataSource = string.IsNullOrEmpty(databaseFolder) ? databaseName : Path.Combine(databaseFolder, databaseName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ShapeAlterationBuilder BoundAs(string bindingSource, Func<DisplayContext,
// ShapeDescriptor.Bindings is a case insensitive dictionary.
descriptor.Bindings[_bindingName] = binding;
descriptor.BindingSources = [..descriptor.BindingSources, bindingSource];
descriptor.BindingSources = [.. descriptor.BindingSources, bindingSource];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private async Task<ShapeBinding> GetShapeBindingAsync(string shapeType, Alternat
});

foreach (var shapeTypeSegment in alternateShapeTypes)
{
{
foreach (var shapeBindingResolver in _shapeBindingResolvers)
{
var binding = await shapeBindingResolver.GetShapeBindingAsync(shapeTypeSegment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Task<IHtmlContent> ShapeExecuteAsync(IShape shape)
}

// Check if the shape is wrapper, return underlying IHtmlContent
if( shape is PositionWrapper wrapper)
if (shape is PositionWrapper wrapper)
{
return Task.FromResult(PositionWrapper.UnWrap(wrapper));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ShapeMetadata()

public void OnDisplaying(Action<ShapeDisplayContext> context)
{
Displaying = [..Displaying, context];
Displaying = [.. Displaying, context];
}

public void OnProcessing(Func<IShape, Task> context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;

namespace OrchardCore.Email;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public static CultureDictionaryRecordKey GetKey(string messageId, string context

return new CultureDictionaryRecordKey
{
MessageId = messageId, Context = context
MessageId = messageId,
Context = context
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task<bool> TrySendAsync(object notify, INotificationMessage message

string body;
bool isHtmlBody;

if (message.IsHtmlPreferred && !string.IsNullOrWhiteSpace(message.HtmlBody))
{
body = message.HtmlBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void ThrowInvalidScopeTypeException()
ThrowInvalidScopeTypeException();
}

var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string) entry.Key));
var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string)entry.Key));

var result = jsScope.Engine.Evaluate(parsedAst).ToObject();

Expand Down
Loading

0 comments on commit 06b0848

Please sign in to comment.