Skip to content

Commit

Permalink
Automatically linting code
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll authored and github-actions[bot] committed Jan 27, 2024
1 parent 6d4414c commit aee8877
Show file tree
Hide file tree
Showing 16 changed files with 344 additions and 266 deletions.
98 changes: 49 additions & 49 deletions sample/Sample.Restful.Client/Sample.Restful.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
PrivateAssets="all"
IncludeAssets="build;contentfiles;analyzers;buildtransitive"
/>
<PackageReference Include="Newtonsoft.Json"/>
<PackageReference Include="NSwag.ApiDescription.Client"/>
<PackageReference Include="System.ComponentModel.Annotations" Condition="'$(TargetFramework)' == 'netstandard2.1'"/>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NSwag.ApiDescription.Client" />
<PackageReference Include="System.ComponentModel.Annotations" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
</ItemGroup>
<ItemGroup>
<OpenApiProjectReference
Expand All @@ -27,39 +27,39 @@

<PropertyGroup>
<NSwagGenerateExceptionClasses>true</NSwagGenerateExceptionClasses>
<NSwagClientBaseClass></NSwagClientBaseClass>
<NSwagConfigurationClass></NSwagConfigurationClass>
<NSwagClientBaseClass />
<NSwagConfigurationClass />
<NSwagGenerateClientClasses>true</NSwagGenerateClientClasses>
<NSwagSuppressClientClassesOutput></NSwagSuppressClientClassesOutput>
<NSwagSuppressClientClassesOutput />
<NSwagGenerateClientInterfaces>true</NSwagGenerateClientInterfaces>
<NSwagSuppressClientInterfacesOutput></NSwagSuppressClientInterfacesOutput>
<NSwagClientBaseInterface></NSwagClientBaseInterface>
<NSwagSuppressClientInterfacesOutput />
<NSwagClientBaseInterface />
<NSwagInjectHttpClient>true</NSwagInjectHttpClient>
<NSwagDisposeHttpClient>false</NSwagDisposeHttpClient>
<NSwagProtectedMethods></NSwagProtectedMethods>
<NSwagExceptionClass></NSwagExceptionClass>
<NSwagProtectedMethods />
<NSwagExceptionClass />
<NSwagWrapDtoExceptions>true</NSwagWrapDtoExceptions>
<NSwagUseHttpClientCreationMethod></NSwagUseHttpClientCreationMethod>
<NSwagHttpClientType></NSwagHttpClientType>
<NSwagUseHttpRequestMessageCreationMethod></NSwagUseHttpRequestMessageCreationMethod>
<NSwagUseHttpClientCreationMethod />
<NSwagHttpClientType />
<NSwagUseHttpRequestMessageCreationMethod />
<NSwagUseBaseUrl>false</NSwagUseBaseUrl>
<NSwagGenerateBaseUrlProperty>false</NSwagGenerateBaseUrlProperty>
<NSwagGenerateSyncMethods></NSwagGenerateSyncMethods>
<NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods></NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods>
<NSwagExposeJsonSerializerSettings></NSwagExposeJsonSerializerSettings>
<NSwagClientClassAccessModifier></NSwagClientClassAccessModifier>
<NSwagTypeAccessModifier></NSwagTypeAccessModifier>
<NSwagGenerateContractsOutput></NSwagGenerateContractsOutput>
<NSwagContractsNamespace></NSwagContractsNamespace>
<NSwagParameterDateTimeFormat></NSwagParameterDateTimeFormat>
<NSwagParameterDateFormat></NSwagParameterDateFormat>
<NSwagGenerateUpdateJsonSerializerSettingsMethod></NSwagGenerateUpdateJsonSerializerSettingsMethod>
<NSwagUseRequestAndResponseSerializationSettings></NSwagUseRequestAndResponseSerializationSettings>
<NSwagSerializeTypeInformation></NSwagSerializeTypeInformation>
<NSwagQueryNullValue></NSwagQueryNullValue>
<NSwagGenerateSyncMethods />
<NSwagGeneratePrepareRequestAndProcessResponseAsAsyncMethods />
<NSwagExposeJsonSerializerSettings />
<NSwagClientClassAccessModifier />
<NSwagTypeAccessModifier />
<NSwagGenerateContractsOutput />
<NSwagContractsNamespace />
<NSwagParameterDateTimeFormat />
<NSwagParameterDateFormat />
<NSwagGenerateUpdateJsonSerializerSettingsMethod />
<NSwagUseRequestAndResponseSerializationSettings />
<NSwagSerializeTypeInformation />
<NSwagQueryNullValue />
<NSwagOperationGenerationMode>MultipleClientsFromFirstTagAndOperationId</NSwagOperationGenerationMode>
<NSwagAdditionalNamespaceUsages></NSwagAdditionalNamespaceUsages>
<NSwagAdditionalContractNamespaceUsages></NSwagAdditionalContractNamespaceUsages>
<NSwagAdditionalNamespaceUsages />
<NSwagAdditionalContractNamespaceUsages />
<NSwagGenerateOptionalParameters>true</NSwagGenerateOptionalParameters>
<NSwagGenerateJsonMethods>false</NSwagGenerateJsonMethods>
<NSwagEnforceFlagEnums>true</NSwagEnforceFlagEnums>
Expand All @@ -68,14 +68,14 @@
<NSwagResponseArrayType>System.Collections.Generic.ICollection</NSwagResponseArrayType>
<NSwagResponseDictionaryType>System.Collections.Generic.IReadOnlyDictionary</NSwagResponseDictionaryType>
<NSwagWrapResponses>true</NSwagWrapResponses>
<NSwagWrapResponseMethods></NSwagWrapResponseMethods>
<NSwagWrapResponseMethods />
<NSwagGenerateResponseClasses>true</NSwagGenerateResponseClasses>
<NSwagResponseClass>Response</NSwagResponseClass>
<NSwagNamespace></NSwagNamespace>
<NSwagNamespace />
<NSwagRequiredPropertiesMustBeDefined>true</NSwagRequiredPropertiesMustBeDefined>
<!-- <NSwagDateType>NodaTime.LocalDate</NSwagDateType>-->
<NSwagJsonConverters></NSwagJsonConverters>
<NSwagAnyType></NSwagAnyType>
<NSwagJsonConverters />
<NSwagAnyType />
<!-- <NSwagDateTimeType>NodaTime.LocalDateTime</NSwagDateTimeType>-->
<!-- <NSwagTimeType>NodaTime.LocalTime</NSwagTimeType>-->
<!-- <NSwagTimeSpanType>NodaTime.Duration</NSwagTimeSpanType>-->
Expand All @@ -86,29 +86,29 @@
<NSwagArrayBaseType>System.Collections.ObjectModel.Collection</NSwagArrayBaseType>
<NSwagDictionaryBaseType>System.Collections.Generic.Dictionary</NSwagDictionaryBaseType>
<NSwagClassStyle>POCO</NSwagClassStyle>
<NSwagJsonLibrary></NSwagJsonLibrary>
<NSwagJsonLibrary />
<NSwagGenerateDefaultValues>true</NSwagGenerateDefaultValues>
<NSwagGenerateDataAnnotations>true</NSwagGenerateDataAnnotations>
<NSwagExcludedTypeNames></NSwagExcludedTypeNames>
<NSwagExcludedParameterNames></NSwagExcludedParameterNames>
<NSwagHandleReferences></NSwagHandleReferences>
<NSwagExcludedTypeNames />
<NSwagExcludedParameterNames />
<NSwagHandleReferences />
<NSwagGenerateImmutableArrayProperties>true</NSwagGenerateImmutableArrayProperties>
<NSwagGenerateImmutableDictionaryProperties>true</NSwagGenerateImmutableDictionaryProperties>
<NSwagJsonSerializerSettingsTransformationMethod></NSwagJsonSerializerSettingsTransformationMethod>
<NSwagInlineNamedArrays></NSwagInlineNamedArrays>
<NSwagInlineNamedDictionaries></NSwagInlineNamedDictionaries>
<NSwagInlineNamedTuples></NSwagInlineNamedTuples>
<NSwagInlineNamedAny></NSwagInlineNamedAny>
<NSwagJsonSerializerSettingsTransformationMethod />
<NSwagInlineNamedArrays />
<NSwagInlineNamedDictionaries />
<NSwagInlineNamedTuples />
<NSwagInlineNamedAny />
<NSwagGenerateDtoTypes>true</NSwagGenerateDtoTypes>
<NSwagGenerateOptionalPropertiesAsNullable>true</NSwagGenerateOptionalPropertiesAsNullable>
<NSwagGenerateNullableReferenceTypes>true</NSwagGenerateNullableReferenceTypes>
<NSwagTemplateDirectory></NSwagTemplateDirectory>
<NSwagTypeNameGeneratorType></NSwagTypeNameGeneratorType>
<NSwagPropertyNameGeneratorType></NSwagPropertyNameGeneratorType>
<NSwagEnumNameGeneratorType></NSwagEnumNameGeneratorType>
<NSwagServiceHost></NSwagServiceHost>
<NSwagServiceSchemes></NSwagServiceSchemes>
<NSwagOutput></NSwagOutput>
<NSwagNewLineBehavior></NSwagNewLineBehavior>
<NSwagTemplateDirectory />
<NSwagTypeNameGeneratorType />
<NSwagPropertyNameGeneratorType />
<NSwagEnumNameGeneratorType />
<NSwagServiceHost />
<NSwagServiceSchemes />
<NSwagOutput />
<NSwagNewLineBehavior />
</PropertyGroup>
</Project>
26 changes: 14 additions & 12 deletions src/AspNetCore.Blazor/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.Blazor;
/// </summary>
public class FluentValidator : ComponentBase
{
private static readonly char[] _separators = { '.', '[' };
private static readonly char[] _separators = { '.', '[', };

private static FieldIdentifier ToFieldIdentifier(EditContext editContext, string propertyPath)
{
Expand All @@ -30,7 +30,7 @@ private static FieldIdentifier ToFieldIdentifier(EditContext editContext, string
var nextTokenEnd = propertyPath.IndexOfAny(_separators);
if (nextTokenEnd < 0)
{
return new FieldIdentifier(obj, propertyPath);
return new(obj, propertyPath);
}

var nextToken = propertyPath.Substring(0, nextTokenEnd);
Expand All @@ -46,7 +46,7 @@ private static FieldIdentifier ToFieldIdentifier(EditContext editContext, string
var prop = obj.GetType().GetProperty("Item")!;
var indexerType = prop.GetIndexParameters()[0].ParameterType;
var indexerValue = Convert.ChangeType(nextToken, indexerType, CultureInfo.InvariantCulture);
newObj = prop.GetValue(obj, new[] { indexerValue });
newObj = prop.GetValue(obj, new[] { indexerValue, });
}
else
{
Expand All @@ -63,7 +63,7 @@ private static FieldIdentifier ToFieldIdentifier(EditContext editContext, string
if (newObj == null)
{
// This is as far as we can go
return new FieldIdentifier(obj, nextToken);
return new(obj, nextToken);
}

obj = newObj;
Expand Down Expand Up @@ -113,8 +113,8 @@ private static async void ValidateField(
{
if (validator != null)
{
var properties = new[] { fieldIdentifier.FieldName };
var context = new ValidationContext<object>(fieldIdentifier.Model, new PropertyChain(), new MemberNameValidatorSelector(properties));
var properties = new[] { fieldIdentifier.FieldName, };
var context = new ValidationContext<object>(fieldIdentifier.Model, new(), new MemberNameValidatorSelector(properties));
var validationResults = await validator.ValidateAsync(context);

messages.Clear(fieldIdentifier);
Expand All @@ -133,23 +133,25 @@ private static async void ValidateField(
public IValidator? Validator { get; set; } = null!;

// ReSharper disable once NullableWarningSuppressionIsUsed
[Inject] private IServiceProvider Services { get; set; } = null!;
[Inject]
private IServiceProvider Services { get; set; } = null!;

// ReSharper disable once NullableWarningSuppressionIsUsed
[CascadingParameter] private EditContext CurrentEditContext { get; set; } = null!;
[CascadingParameter]
private EditContext CurrentEditContext { get; set; } = null!;

/// <inheritdoc />
protected override void OnInitialized()
{
if (CurrentEditContext == null)
{
throw new InvalidOperationException(
$"{nameof(FluentValidator)} requires a cascading " +
$"parameter of type {nameof(EditContext)}. For example, you can use {nameof(FluentValidator)} " +
$"inside an {nameof(EditForm)}."
$"{nameof(FluentValidator)} requires a cascading "
+ $"parameter of type {nameof(EditContext)}. For example, you can use {nameof(FluentValidator)} "
+ $"inside an {nameof(EditForm)}."
);
}

AddFluentValidation(Validator, CurrentEditContext, Services);
}
}
}
48 changes: 23 additions & 25 deletions src/AspNetCore/Conventions/FluentValidationConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ private static void AddFluentValidationRules(IServiceCollection services)
.WithApply(
context =>
{
var ruleContext = ((ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)!)
var ruleContext = ( (ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)! )
.GetReflectionContext();
var propertyType = ruleContext?.PropertyInfo?.DeclaringType;
if (propertyType == typeof(string))
Expand All @@ -54,16 +54,14 @@ private static void AddFluentValidationRules(IServiceCollection services)
.WithApply(
context =>
{
var ruleContext = ((ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)!)
var ruleContext = ( (ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)! )
.GetReflectionContext();
var propertyType = ruleContext?.PropertyInfo?.DeclaringType;
if (propertyType != null &&
( ( propertyType.IsValueType && Nullable.GetUnderlyingType(propertyType) == null ) ||
propertyType.IsEnum ))
if (propertyType != null && ( ( propertyType.IsValueType && Nullable.GetUnderlyingType(propertyType) == null ) || propertyType.IsEnum ))
{
context.Schema.Required.Add(context.PropertyKey);
context.Schema.Properties[context.PropertyKey].Nullable = false;
Expand All @@ -77,11 +75,11 @@ private static void AddFluentValidationRules(IServiceCollection services)
.WithApply(
context =>
{
var ruleContext = ((ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)!)
var ruleContext = ( (ValidationRuleContext)context
.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)
.First(z => z.PropertyType == typeof(ValidationRuleContext))
.GetValue(context)! )
.GetReflectionContext();
context.Schema.Properties[context.PropertyKey].Nullable =
context.PropertyValidator is not (INotNullValidator or INotEmptyValidator)
Expand All @@ -91,12 +89,12 @@ context.PropertyValidator is not (INotNullValidator or INotEmptyValidator)
static bool getNullableValue(Nullability nullability, Type propertyType)
{
return nullability switch
{
Nullability.Nullable => true,
Nullability.NonNullable => false,
Nullability.NotDefined => !propertyType.IsValueType || Nullable.GetUnderlyingType(propertyType) is not null,
_ => false
};
{
Nullability.Nullable => true,
Nullability.NonNullable => false,
Nullability.NotDefined => !propertyType.IsValueType || Nullable.GetUnderlyingType(propertyType) is { },
_ => false,
};
}
}
)
Expand Down Expand Up @@ -132,4 +130,4 @@ public void Register(IConventionContext context, IConfiguration configuration, I

AddFluentValidationRules(services);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I
{
"Serilog:MinimumLevel:Default",
LevelConvert.ToSerilogLevel(applicationLogLevel.Value).ToString()
}
},
}
);
}
Expand All @@ -67,4 +67,4 @@ LoggerConfiguration loggerConfiguration

loggerConfiguration.ReadFrom.Configuration(configuration);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public void Register(IConventionContext context, IConfiguration configuration, I
services.AddSingleton<ISerializer, GeometrySerializer>();
// services.AddSerializer<CoordinatesSerializer>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public void Register(IConventionContext context, IConfiguration configuration, I
services.AddSingleton<ISerializer, OffsetSerializer>();
services.AddSingleton<ISerializer, IsoDayOfWeekSerializer>();
}
}
}
Loading

0 comments on commit aee8877

Please sign in to comment.