Skip to content

Commit

Permalink
WebApiHost (#82)
Browse files Browse the repository at this point in the history
* Re-add those projects to solution
* API host Implementation
* Fix vulnerable versions without bump
* WebApi Host finalized
* Include FeatureManagement
* Add FeatureManager

* Add PS1 script zur Erzeugung neuer Libraries
* Finalize WebAPI-Host
* Enable Claim based feature filter

* Expose some of the builders
* Build pipeline
* Rough readme
* XMLDocs
* Clean up warnings
* Preview version

---------

Co-authored-by: Ottenhus, Thomas <[email protected]>
  • Loading branch information
glatzert and Ottenhus, Thomas authored Feb 21, 2024
1 parent 5431247 commit 4997d0a
Show file tree
Hide file tree
Showing 39 changed files with 1,670 additions and 298 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion

#### Naming styles ####
[*.{cs,vb}]
Expand Down Expand Up @@ -370,4 +371,5 @@ tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_prefer_collection_expression = true:suggestion

23 changes: 23 additions & 0 deletions .github/workflows/JGUZDV.WebApiHost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: JGUZDV.WebApiHost

on:
workflow_dispatch:
inputs:
push-to-nuget:
description: Push package to NuGet
type: boolean

pull_request:
branches:
- main
paths:
- libraries/JGUZDV.WebApiHost/**

jobs:
call_default_build:
uses: ./.github/workflows/default_build.yml
with:
library-name: JGUZDV.WebApiHost
push-to-nuget: ${{ inputs.push-to-nuget != '' && inputs.push-to-nuget }}
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
19 changes: 19 additions & 0 deletions AddLibrary.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
param(
[Parameter(Mandatory = $true, ValueFromPipeline=$true)]
[string] $LibraryName,

[Parameter()]
[string] $Template = 'classlib'
)

process {
Push-Location $PSScriptRoot

Invoke-Expression "dotnet new $Template -n $LibraryName -o ./libraries/$LibraryName/src"
Invoke-Expression "dotnet new xunit -n $LibraryName.Tests -o ./libraries/$LibraryName/test"

Invoke-Expression "dotnet sln . add ./libraries/$LibraryName/src"
Invoke-Expression "dotnet sln . add ./libraries/$LibraryName/test"

Pop-Location
}
941 changes: 707 additions & 234 deletions NuGet-Packages.sln

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions libraries/JGUZDV.AspNetCore.DataProtection/src/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
namespace JGUZDV.AspNetCore.DataProtection;

/// <summary>
/// Public constants for this package
/// </summary>
public static class Constants
{
/// <summary>
/// Default section name for the configuration
/// </summary>
public const string DefaultSectionName = "JGUZDV:DataProtection";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

namespace JGUZDV.AspNetCore.DataProtection;

/// <summary>
/// Extension methods for configuring data protection.
/// </summary>
public static class DataProtectionBuilderExtensions
{

/// <summary>
/// Configures the data protection system with the specified configuration.
/// </summary>
public static IDataProtectionBuilder UseDataProtectionConfig(this IDataProtectionBuilder builder, IConfigurationSection configuration, IWebHostEnvironment? environment)
{
var config = new Configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods for configuring data protection.
/// </summary>
public static class JGUZDVDataProtectionExtensions
{
/// <summary>
/// Adds data protection to the application using the specified configuration.
/// </summary>
public static IDataProtectionBuilder AddJGUZDVDataProtection(this IServiceCollection services, IConfigurationSection configurationSection, IWebHostEnvironment? environment = null)
=> services.AddDataProtection().UseDataProtectionConfig(configurationSection, environment);


/// <summary>
/// Adds data protection to the application using the specified configuration.
/// </summary>
public static IDataProtectionBuilder AddJGUZDVDataProtection(this IServiceCollection services, IConfiguration config, IWebHostEnvironment? environment = null)
=> services.AddJGUZDVDataProtection(config.GetSection(Constants.DefaultSectionName), environment);


/// <summary>
/// Adds data protection to the application using the specified configuration.
/// </summary>
public static IDataProtectionBuilder AddJGUZDVDataProtection(this WebApplicationBuilder builder, string sectionName = Constants.DefaultSectionName)
=> builder.Services.AddJGUZDVDataProtection(builder.Configuration.GetSection(sectionName), builder.Environment);
}
8 changes: 0 additions & 8 deletions libraries/JGUZDV.AspNetCore.Logging/src/Constants.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using JGUZDV.AspNetCore.Logging;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;

namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods for configuring logging.
/// </summary>
public static class JGUZDVLoggingExtensions
{
public static WebApplicationBuilder UseJGUZDVLogging(this WebApplicationBuilder builder, string configSectionName = Constants.DefaultSectionName)
/// <summary>
/// Configures the web host to use the default logging configuration.
/// </summary>
public static WebApplicationBuilder UseJGUZDVLogging(this WebApplicationBuilder builder, string configSectionName = JGUZDV.Extensions.Logging.Constants.DefaultSectionName)
{
builder.Host.UseJGUZDVLogging(configSectionName);
return builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AddButton.AddClaimRequirement" xml:space="preserve">
<value>Ajouter une règle de type/valeur</value>
</data>
<data name="AddButton.AddClaimRequirementCollection" xml:space="preserve">
<value>Ajouter un ensemble de règles</value>
</data>
<data name="ClaimRequirement.ClaimType" xml:space="preserve">
<value>Taper</value>
</data>
<data name="ClaimRequirement.ClaimValue" xml:space="preserve">
<value>Valeur</value>
</data>
<data name="CollectionEditor.ChooseMatching" xml:space="preserve">
<value>Sélectionner un raccourci</value>
</data>
<data name="CollectionEditor.MatchAll" xml:space="preserve">
<value>Tous (ET)</value>
</data>
<data name="CollectionEditor.MatchAny" xml:space="preserve">
<value>Au moins un (OU)</value>
</data>
<data name="Editor.Delete" xml:space="preserve">
<value>Supprimer</value>
</data>
<data name="Editor.Discard" xml:space="preserve">
<value>jeter</value>
</data>
<data name="Editor.Save" xml:space="preserve">
<value>Sauvegarder</value>
</data>
<data name="ValueEditor.ClaimTypeStringComparison" xml:space="preserve">
<value>Comparaison type pour type</value>
</data>
<data name="ValueEditor.ClaimValueStringComparison" xml:space="preserve">
<value>Type de comparaison pour la valeur</value>
</data>
<data name="ValueEditor.NoWildcardMatch" xml:space="preserve">
<value>Désactivez le caractère générique (*)</value>
</data>
<data name="Viewer.And" xml:space="preserve">
<value>ET</value>
</data>
<data name="Viewer.ClaimUndefined" xml:space="preserve">
<value>Aucune règle n'a été définie.</value>
</data>
<data name="Viewer.ComparisonType" xml:space="preserve">
<value>Type de comparaison</value>
</data>
<data name="Viewer.ComparisonTypes" xml:space="preserve">
<value>Types de comparaison</value>
</data>
<data name="Viewer.Or" xml:space="preserve">
<value>OU</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,4 @@
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="[7.0.0,)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="[7.0.0,)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="[7.0.14,)" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="[7.0.14,)" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="[7.0.0,)" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="[7.0.0,)" />
<PackageReference Include="Microsoft.Bcl.TimeProvider" Version="[8.0.0,)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="[7.0.0,)" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="[7.0.14,)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="bunit" Version="1.24.10" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion libraries/JGUZDV.CQRS/src/CQRSDecoratorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
/// <summary>
/// Flags a class as a "Decorator".
/// Decorators won't be automatically registered as ICommandHandler<> or IQueryHandler<> during DI setup.
/// Decorators won't be automatically registered as ICommandHandler&lt;&gt; or IQueryHandler&lt;&gt; during DI setup.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public sealed class CQRSDecoratorAttribute : Attribute { }
Expand Down
Loading

0 comments on commit 4997d0a

Please sign in to comment.