chore: Initial commit:wq
This commit is contained in:
commit
edd7dedf3c
|
|
@ -0,0 +1,2 @@
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
name: Continuous Deployment
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/Checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install Dotnet
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '9.0.303'
|
||||||
|
- name: Install Gitversion
|
||||||
|
uses: gittools/actions/gitversion/setup@v4.0.1
|
||||||
|
with:
|
||||||
|
versionSpec: '6.3.0'
|
||||||
|
- name: Determine Version
|
||||||
|
id: version_step
|
||||||
|
uses: gittools/actions/gitversion/execute@v4.0.1
|
||||||
|
inputs:
|
||||||
|
updateAssemblyInfo: true
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build -c Release --no-restore
|
||||||
|
- name: Pack
|
||||||
|
run: dotnet pack -c Release --no-build --no-restore /p:PackageVersion=${{ env.fullSemVer }}
|
||||||
|
- name: Push
|
||||||
|
run: dotnet nuget push ./src/MetiSyn.Extensions.Options/bin/Release/MetiSyn.Extensions.Options.${{ env.FullSemVer }}.nupkg -s https://gitea.evileric.io/api/packages/metisyn.io/nuget/index.json -k ${{ secrets.PUBLISH_TOKEN }}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
name: Continuous Integration
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '.gitea/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/Checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install Dotnet
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '9.0.303'
|
||||||
|
- name: Install Gitversion
|
||||||
|
uses: gittools/actions/gitversion/setup@v4.0.1
|
||||||
|
with:
|
||||||
|
versionSpec: '6.3.0'
|
||||||
|
- name: Determine Version
|
||||||
|
id: version_step
|
||||||
|
uses: gittools/actions/gitversion/execute@v4.0.1
|
||||||
|
inputs:
|
||||||
|
updateAssemblyInfo: true
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build -c Release --no-restore
|
||||||
|
- name: Pack
|
||||||
|
run: dotnet pack -c Release --no-build --no-restore /p:PackageVersion=${{ env.fullSemVer }}
|
||||||
|
- name: Push
|
||||||
|
run: dotnet nuget push ./src/MetiSyn.Extensions.Options/bin/Release/MetiSyn.Extensions.Options.${{ env.FullSemVer }}.nupkg -s https://gitea.evileric.io/api/packages/metisyn.io/nuget/index.json -k ${{ secrets.PUBLISH_TOKEN }}
|
||||||
|
|
@ -0,0 +1,427 @@
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,dotnetcore
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio,visualstudiocode,dotnetcore
|
||||||
|
|
||||||
|
### DotnetCore ###
|
||||||
|
# .NET Core build folders
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
|
||||||
|
# Common node modules locations
|
||||||
|
/node_modules
|
||||||
|
/wwwroot/node_modules
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
### VisualStudio ###
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||||
|
*.vbp
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
|
||||||
|
# Visual Studio 6 technical files
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# Visual Studio History (VSHistory) files
|
||||||
|
.vshistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
### VisualStudio Patch ###
|
||||||
|
# Additional files built by Visual Studio
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,dotnetcore
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-,/\\\\]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
|
||||||
|
minor-version-bump-message: "^(feat)(\\([\\w\\s-,/\\\\]*\\))?:"
|
||||||
|
patch-version-bump-message: "^(fix|perf)(\\([\\w\\s-,/\\\\]*\\))?:"
|
||||||
|
assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}'
|
||||||
|
assembly-versioning-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}'
|
||||||
|
assembly-informational-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}'
|
||||||
|
label: "preview"
|
||||||
|
branches:
|
||||||
|
main:
|
||||||
|
label: "preview"
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Solution>
|
||||||
|
<Folder Name="/Solution Items/">
|
||||||
|
<File Path=".editorconfig" />
|
||||||
|
</Folder>
|
||||||
|
<Folder Name="/src/">
|
||||||
|
<File Path="src/Directory.Build.props" />
|
||||||
|
<Project Path="src/MetiSyn.Extensions.Options/MetiSyn.Extensions.Options.csproj" />
|
||||||
|
</Folder>
|
||||||
|
<Folder Name="/test/">
|
||||||
|
<Project Path="test/MetiSyn.Extensions.Options.TrimmingTest/MetiSyn.Extensions.Options.TrimmingTest.csproj" Id="44b99300-9ac1-44b6-a546-e7c6c7e4d2b2" />
|
||||||
|
<Project Path="test/MetiSyn.Extensions.Options.UnitTest/MetiSyn.Extensions.Options.UnitTest/MetiSyn.Extensions.Options.UnitTest.csproj" Id="f2264aa9-e179-43ac-af1b-ac3225bb7348" />
|
||||||
|
</Folder>
|
||||||
|
</Solution>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>preview</LangVersion>
|
||||||
|
<IsAotCompatible>true</IsAotCompatible>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
global using Microsoft.Extensions.Options;
|
||||||
|
global using Microsoft.Extensions.DependencyInjection;
|
||||||
|
global using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
global using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<InternalsVisibleTo Include="MetiSyn.Extensions.Options.UnitTest"/>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
|
||||||
|
public interface INamedOptions<[DynamicallyAccessedMembers(NamedOptions.DynamicallyAccessedMembers)] out TOptions> : IOptions<TOptions> where TOptions: class {
|
||||||
|
TOptions Get();
|
||||||
|
TOptions Get(string name);
|
||||||
|
IEnumerable<string> GetNames();
|
||||||
|
IEnumerable<TOptions> GetAll();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
internal interface INamedOptionsFactory<[DynamicallyAccessedMembers(NamedOptions.DynamicallyAccessedMembers)] TOptions> {
|
||||||
|
TOptions Create(string name);
|
||||||
|
IEnumerable<string> GetNames();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
public static class NamedOptions {
|
||||||
|
internal const DynamicallyAccessedMemberTypes DynamicallyAccessedMembers = DynamicallyAccessedMemberTypes.PublicParameterlessConstructor;
|
||||||
|
|
||||||
|
public static readonly string DefaultName = string.Empty;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
internal class NamedOptionsFactory<[DynamicallyAccessedMembers(NamedOptions.DynamicallyAccessedMembers)] TOptions>
|
||||||
|
: INamedOptionsFactory<TOptions> where TOptions : class {
|
||||||
|
|
||||||
|
private readonly IConfigureOptions<TOptions>[] _setups;
|
||||||
|
private readonly IPostConfigureOptions<TOptions>[] _postConfigures;
|
||||||
|
private readonly IValidateOptions<TOptions>[] _validations;
|
||||||
|
|
||||||
|
public NamedOptionsFactory(IEnumerable<IConfigureOptions<TOptions>> setups, IEnumerable<IPostConfigureOptions<TOptions>> postConfigures, IEnumerable<IValidateOptions<TOptions>> validations) {
|
||||||
|
_setups = setups as IConfigureOptions<TOptions>[] ?? new List<IConfigureOptions<TOptions>>().ToArray();
|
||||||
|
_postConfigures = postConfigures as IPostConfigureOptions<TOptions>[] ?? new List<IPostConfigureOptions<TOptions>>().ToArray();
|
||||||
|
_validations = validations as IValidateOptions<TOptions>[] ?? new List<IValidateOptions<TOptions>>().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TOptions Create(string name) {
|
||||||
|
TOptions options = CreateInstance(name);
|
||||||
|
|
||||||
|
foreach (IConfigureOptions<TOptions> setup in _setups) {
|
||||||
|
if (setup is IConfigureNamedOptions<TOptions> namedSetup) {
|
||||||
|
namedSetup.Configure(name, options);
|
||||||
|
}
|
||||||
|
else if(name == NamedOptions.DefaultName) {
|
||||||
|
setup.Configure(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(IPostConfigureOptions<TOptions> post in _postConfigures) {
|
||||||
|
post.PostConfigure(name, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_validations.Length > 0) {
|
||||||
|
List<string> failures = new();
|
||||||
|
foreach (IValidateOptions<TOptions> validate in _validations) {
|
||||||
|
ValidateOptionsResult result = validate.Validate(name, options);
|
||||||
|
if (result is not null && result.Failed) {
|
||||||
|
failures.AddRange(result.Failures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (failures.Count > 0) {
|
||||||
|
throw new OptionsValidationException(name, typeof(TOptions), failures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> GetNames()
|
||||||
|
=> _setups.Select(s => (s as NamedConfigureFromConfigurationOptions<TOptions>)?.Name??String.Empty).Where(s => string.IsNullOrEmpty(s) == false);
|
||||||
|
protected virtual TOptions CreateInstance(string name)
|
||||||
|
=> Activator.CreateInstance<TOptions>();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
internal class NamedOptionsManager<[DynamicallyAccessedMembers(NamedOptions.DynamicallyAccessedMembers)] TOptions> : IOptions<TOptions>, INamedOptions<TOptions> where TOptions : class {
|
||||||
|
private readonly INamedOptionsFactory<TOptions> _factory;
|
||||||
|
private readonly OptionsCache<TOptions> _cache;
|
||||||
|
|
||||||
|
public NamedOptionsManager(INamedOptionsFactory<TOptions> factory) {
|
||||||
|
_factory = factory;
|
||||||
|
_cache = new OptionsCache<TOptions>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TOptions Value => Get();
|
||||||
|
|
||||||
|
public TOptions Get() => Get(NamedOptions.DefaultName);
|
||||||
|
|
||||||
|
public TOptions Get(string name) {
|
||||||
|
name = name ?? NamedOptions.DefaultName;
|
||||||
|
return _cache.GetOrAdd(name, () => _factory.Create(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<TOptions> GetAll() => GetNames().Select(Get);
|
||||||
|
|
||||||
|
public IEnumerable<string> GetNames() => _factory.GetNames();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace MetiSyn.Extensions.Options;
|
||||||
|
public static class ServiceCollectionExtensions {
|
||||||
|
extension(IServiceCollection services) {
|
||||||
|
public IServiceCollection AddNamedOptions() {
|
||||||
|
services.AddOptions();
|
||||||
|
services.TryAdd(ServiceDescriptor.Singleton(typeof(INamedOptions<>), typeof(NamedOptionsManager<>)));
|
||||||
|
services.TryAdd(ServiceDescriptor.Transient(typeof(INamedOptionsFactory<>), typeof(NamedOptionsFactory<>)));
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
|
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\MetiSyn.Extensions.Options\MetiSyn.Extensions.Options.csproj" />
|
||||||
|
<TrimmerRootAssembly Include="MetiSyn.Extensions.Options" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using MetiSyn.Extensions.Options;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
Dictionary<string, string?> configSource = new() {
|
||||||
|
{ "Section1:Item1", "Value1" },
|
||||||
|
};
|
||||||
|
|
||||||
|
IConfigurationRoot Configuration = new ConfigurationBuilder()
|
||||||
|
.AddInMemoryCollection(configSource)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
ServiceCollection services = new ();
|
||||||
|
services.AddNamedOptions();
|
||||||
|
|
||||||
|
services.Configure<SampleConfig>("Section1", Configuration.GetSection("Section1"));
|
||||||
|
|
||||||
|
IServiceProvider serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
INamedOptions<SampleConfig>? option = serviceProvider.GetService<INamedOptions<SampleConfig>>();
|
||||||
|
if(option is null) throw new ArgumentNullException(nameof(option));
|
||||||
|
|
||||||
|
SampleConfig? config = option.Get("Section1");
|
||||||
|
if(config is null) throw new ArgumentNullException(nameof(config));
|
||||||
|
|
||||||
|
|
||||||
|
public record SampleConfig() {
|
||||||
|
public string? Item1 { get; set; }
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Here you could define global logic that would affect all tests
|
||||||
|
|
||||||
|
// You can use attributes at the assembly level to apply to all tests in the assembly
|
||||||
|
[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0-preview.6.25358.103" />
|
||||||
|
<PackageReference Include="TUnit" Version="0.25.21" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\src\MetiSyn.Extensions.Options\MetiSyn.Extensions.Options.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace MetiSyn.Extensions.Options.UnitTest;
|
||||||
|
|
||||||
|
public class Tests {
|
||||||
|
[Test]
|
||||||
|
public async Task Test() {
|
||||||
|
ServiceCollection services = new ();
|
||||||
|
services.AddNamedOptions();
|
||||||
|
|
||||||
|
// Verify that AddOptions was called
|
||||||
|
await Assert.That(services.Any(sd => sd.ServiceType == typeof(IOptions<>))).IsTrue();
|
||||||
|
|
||||||
|
// Verify that the expected services were registered
|
||||||
|
await Assert.That(services.Any(sd => sd.ServiceType == typeof(INamedOptions<>))).IsTrue();
|
||||||
|
await Assert.That(services.Any(sd => sd.ServiceType == typeof(INamedOptionsFactory<>))).IsTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.MapGet("/ping", () => "Hello, World!");
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
public partial class Program;
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:24820",
|
||||||
|
"sslPort": 44340
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5298",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "https://localhost:7061;http://localhost:5298",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
@WebApp_HostAddress = http://localhost:5298
|
||||||
|
|
||||||
|
GET {{WebApp_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue