Skip to content

Commit

Permalink
Updated target framework and FV version. Refactored to eliminate warn…
Browse files Browse the repository at this point in the history
…ings.
  • Loading branch information
Scandal-UK committed Feb 2, 2024
1 parent a881a87 commit 9db9327
Show file tree
Hide file tree
Showing 41 changed files with 2,674 additions and 2,782 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.x'

# Build and run the unit tests
- name: Restore project
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: '8.x'

- name: Create build with released version number
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
// Copyright (c) Dan Ware. All rights reserved.
// </copyright>

namespace FluentValidationLister.Filter.DependencyInjection
{
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
namespace FluentValidationLister.Filter.DependencyInjection;

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;

public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds a global <see cref="IActionFilter"/> for returning serialised lists of validation rules and messages.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
/// <returns>The <see cref="IServiceCollection"/> for further customisation.</returns>
public static IServiceCollection AddFluentValidationLister(this IServiceCollection services) =>
services
.Configure<MvcOptions>(o =>
{
o.Filters.Add(typeof(ValidationActionFilter));
});
}
/// <summary> Class to encapsulate dependency injection methods. </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds a global <see cref="IActionFilter"/> for returning serialised lists of validation rules and messages.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
/// <returns>The <see cref="IServiceCollection"/> for further customisation.</returns>
public static IServiceCollection AddFluentValidationLister(this IServiceCollection services) =>
services
.Configure<MvcOptions>(o =>
{
o.Filters.Add(typeof(ValidationActionFilter));
});
}
73 changes: 38 additions & 35 deletions FluentValidationLister.Filter/FluentValidationLister.Filter.csproj
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Authors>Dan Ware</Authors>
<Product>FluentValidationLister</Product>
<PackageTags>remote validation;fluentvalidation;clientside;javascript;lister;metadata;meta-data;centralised;centralized;dynamic</PackageTags>
<Description>ASP.NET Core extension for FluentValidation to provide additional endpoints that describe validator metadata for a Web API project.</Description>
<RepositoryUrl>https://github.com/scandal-uk/fluentvalidationlister</RepositoryUrl>
</PropertyGroup>

<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.4.0</Version>
<PackageLicenseFile></PackageLicenseFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReleaseNotes>Updated to FluentValidation 11.0.0</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright (c) Dan Ware 2022</Copyright>
<PackageProjectUrl>https://coderware.co.uk</PackageProjectUrl>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Authors>Dan Ware</Authors>
<Product>FluentValidationLister</Product>
<PackageTags>remote validation;fluentvalidation;clientside;javascript;lister;metadata;meta-data;centralised;centralized;dynamic</PackageTags>
<Description>ASP.NET Core extension for FluentValidation to provide additional endpoints that describe validator metadata for a Web API project.</Description>
<RepositoryUrl>https://github.com/scandal-uk/fluentvalidationlister</RepositoryUrl>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>1.5.0</Version>
<PackageLicenseFile></PackageLicenseFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReleaseNotes>Updated to FluentValidation 11.4.0</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<Copyright>Copyright (c) Dan Ware 2024</Copyright>
<PackageProjectUrl>https://coderware.co.uk</PackageProjectUrl>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
83 changes: 41 additions & 42 deletions FluentValidationLister.Filter/Internal/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,63 @@
// Copyright (c) Dan Ware. All rights reserved.
// </copyright>

namespace FluentValidationLister.Filter.Internal
{
using System.Collections.Generic;
using System.Globalization;
namespace FluentValidationLister.Filter.Internal;

using System.Collections.Generic;
using System.Globalization;

/// <summary>
/// Class to provide additional functionality for strings.
/// </summary>
internal static class StringExtensions
{
/// <summary>
/// Class to provide additional functionality for strings.
/// Returns the string with the first character switched to lower case.
/// </summary>
internal static class StringExtensions
/// <param name="input">Current string for which to make the first letter lower case.</param>
/// <returns>Formatted string.</returns>
public static string ToCamelCase(this string input)
{
/// <summary>
/// Returns the string with the first character switched to lower case.
/// </summary>
/// <param name="input">Current string for which to make the first letter lower case.</param>
/// <returns>Formatted string.</returns>
public static string ToCamelCase(this string input)
if (string.IsNullOrEmpty(input) || !char.IsUpper(input[0]))
{
if (string.IsNullOrEmpty(input) || !char.IsUpper(input[0]))
{
return input;
}
return input;
}

if (input.Contains('.'))
if (input.Contains('.'))
{
var parts = input.Split('.');
var camelCasedParts = new List<string>();
foreach (var part in parts)
{
var parts = input.Split('.');
var camelCasedParts = new List<string>();
foreach (var part in parts)
{
camelCasedParts.Add(StringToCamelCase(part));
}

return string.Join(".", camelCasedParts);
camelCasedParts.Add(StringToCamelCase(part));
}

return StringToCamelCase(input);
return string.Join(".", camelCasedParts);
}

private static string StringToCamelCase(string input)
{
var chars = input.ToCharArray();
return StringToCamelCase(input);
}

for (var i = 0; i < chars.Length; i++)
{
if (i == 1 && !char.IsUpper(chars[i]))
{
break;
}
private static string StringToCamelCase(string input)
{
var chars = input.ToCharArray();

var hasNext = i + 1 < chars.Length;
if (i > 0 && hasNext && !char.IsUpper(chars[i + 1]))
{
break;
}
for (var i = 0; i < chars.Length; i++)
{
if (i == 1 && !char.IsUpper(chars[i]))
{
break;
}

chars[i] = char.ToLower(chars[i], CultureInfo.InvariantCulture);
var hasNext = i + 1 < chars.Length;
if (i > 0 && hasNext && !char.IsUpper(chars[i + 1]))
{
break;
}

return new string(chars);
chars[i] = char.ToLower(chars[i], CultureInfo.InvariantCulture);
}

return new string(chars);
}
}
Loading

0 comments on commit 9db9327

Please sign in to comment.