diff --git a/.editorconfig b/.editorconfig index 3c8f65b..e270271 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,11 @@ ; This is the default for the codeline. root = true +; For disabling MA0048 and MA0051 in a specific folder, e.g., Migrations +[**/Migrations/*.cs] +dotnet_diagnostic.MA0048.severity = none +dotnet_diagnostic.MA0051.severity = none + [*] indent_style = space charset = utf-8 @@ -57,16 +62,16 @@ csharp_prefer_braces = true # Prefer curly braces even for one line of code # name all constant fields using PascalCase dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion -dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style -dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style +dotnet_naming_symbols.constant_fields.applicable_kinds = field dotnet_naming_symbols.constant_fields.required_modifiers = const dotnet_naming_style.pascal_case_style.capitalization = pascal_case # internal and private fields should be _camelCase dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style dotnet_naming_symbols.private_internal_fields.applicable_kinds = field dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal dotnet_naming_style.camel_case_underscore_style.required_prefix = _ @@ -294,7 +299,7 @@ dotnet_diagnostic.IDE0031.severity = warning dotnet_diagnostic.IDE0035.severity = warning # IDE0036: Order modifiers -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion +csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:suggestion dotnet_diagnostic.IDE0036.severity = warning # IDE0038: Use pattern matching to avoid is check followed by a cast (without variable) diff --git a/.gitea/workflows/server.yaml b/.gitea/workflows/server.yaml index 1e75ce9..bdb37bf 100644 --- a/.gitea/workflows/server.yaml +++ b/.gitea/workflows/server.yaml @@ -1,32 +1,42 @@ -name: Test if Server can be built +name: Build, Package and Push Images run-name: ${{ gitea.actor }} is building the Server application on: [ push ] jobs: - build-server: + preprocess: + runs-on: ubuntu-latest + outputs: + sanitized_branch_name: ${{ steps.sanitize.outputs.sanitized_branch_name }} + steps: + - name: Sanitize branch name + id: sanitize + run: echo "::set-output name=sanitized_branch_name::$(echo ${{ github.ref_name }} | sed 's/\//-/g')" + + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup dotnet uses: https://github.com/actions/setup-dotnet@v3 with: - dotnet-version: 7.0 + dotnet-version: 8.0 - name: Install dependencies run: dotnet restore - name: Build run: | dotnet build Server -c Release # dotnet test Server.Tests -c Release + sonarqube: - needs: build-server + needs: build runs-on: ubuntu-latest - if: gitea.ref == 'refs/heads/master' + if: github.ref_name == 'master' steps: - uses: actions/checkout@v3 - name: Setup dotnet uses: https://github.com/actions/setup-dotnet@v3 with: - dotnet-version: 7.0 + dotnet-version: 8.0 - name: Install dependencies run: | dotnet restore @@ -48,16 +58,18 @@ jobs: - name: Sonarqube End run: | dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - dependency-track: - needs: build-server + + sbom-scan: + needs: build runs-on: ubuntu-latest - if: gitea.ref == 'refs/heads/master' steps: - uses: actions/checkout@v3 - name: Setup dotnet uses: https://github.com/actions/setup-dotnet@v3 with: - dotnet-version: 7.0 + dotnet-version: | + 7.0 + 8.0 - name: Install dependencies run: | dotnet restore @@ -76,5 +88,84 @@ jobs: projectName: ${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }} autoCreate: true # set projectversion to be the branch name - projectVersion: $GITHUB_REF_NAME + projectVersion: "${{ github.ref_name }}" bomFilename: "${{ github.workspace }}/bom.xml" + + container-build: + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + needs: [ build, preprocess ] + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: https://github.com/actions/setup-dotnet@v3 + with: + dotnet-version: 8.0 + # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ github.server_url }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: Server/Dockerfile + push: true + tags: forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }} + platforms: linux/amd64,linux/arm64 + - name: Build and push to latest + if: github.ref_name == 'master' + uses: docker/build-push-action@v5 + with: + context: . + file: Server/Dockerfile + push: true + tags: forge.rainote.dev/${{ github.repository }}:latest + platforms: linux/amd64, linux/arm64 + + container-sbom-scan: + needs: [ container-build, preprocess ] + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: https://github.com/actions/setup-dotnet@v3 + with: + dotnet-version: 8.0 + - name: Install dependencies + run: | + dotnet restore + echo "::add-path::$HOME/.dotnet/tools" + - name: Setup Dependency Track Dependencies + run: | + mkdir ~/.docker + curl -sSfL https://raw.githubusercontent.com/docker/sbom-cli-plugin/main/install.sh | sh -s -- + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ github.server_url }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + - name: Generate SBOM + run: | + docker sbom forge.rainote.dev/${{ github.repository }}:${{ needs.preprocess.outputs.sanitized_branch_name }} --format cyclonedx-json --output bom.json + - name: Upload SBOM + uses: https://github.com/DependencyTrack/gh-upload-sbom@v2.0.1 + with: + apiKey: ${{ secrets.DEPENDENCY_TRACK_API_KEY }} + serverHostname: ${{ secrets.DEPENDENCY_TRACK_URL }} + projectName: "${{ secrets.DEPENDENCY_TRACK_PROJECT_NAME }}-container" + autoCreate: true + # set projectversion to be the branch name + projectVersion: "${{ github.ref_name }}" + bomFilename: "${{ github.workspace }}/bom.json" + diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj index a34ace0..8b71371 100644 --- a/Benchmarks/Benchmarks.csproj +++ b/Benchmarks/Benchmarks.csproj @@ -9,7 +9,11 @@ - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Benchmarks/BinaryConversionBenchmarks.cs b/Benchmarks/BinaryConversionBenchmarks.cs index f6d7eee..74cef4c 100644 --- a/Benchmarks/BinaryConversionBenchmarks.cs +++ b/Benchmarks/BinaryConversionBenchmarks.cs @@ -14,7 +14,7 @@ using BenchmarkDotNet.Order; [ThreadingDiagnoser] public class BinaryConversionBenchmarks { - private byte[] _data; + private byte[] _data = null!; private int _offset; [GlobalSetup] diff --git a/Continuity.sln b/Continuity.sln index 86836c8..a8a1984 100644 --- a/Continuity.sln +++ b/Continuity.sln @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{7D560FA1-A61C-4B67-8300-835CA5814621}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonderking", "Wonderking\Wonderking.csproj", "{6B53A10B-C397-4347-BB00-A12272D0528E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {7D560FA1-A61C-4B67-8300-835CA5814621}.Debug|Any CPU.Build.0 = Debug|Any CPU {7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.ActiveCfg = Release|Any CPU {7D560FA1-A61C-4B67-8300-835CA5814621}.Release|Any CPU.Build.0 = Release|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B53A10B-C397-4347-BB00-A12272D0528E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Server/.dockerignore b/Server/.dockerignore new file mode 100644 index 0000000..a72b3bb --- /dev/null +++ b/Server/.dockerignore @@ -0,0 +1,1227 @@ +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### ASPNETCore template +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.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 + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# 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 +# 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 +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable 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 + +# 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 +node_modules/ +orleans.codegen.cs + +# 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 + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# 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/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ + +### VisualStudio template +## 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 +*.ncb +*.aps + +# 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 +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### Csharp template +## 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 +*.ncb +*.aps + +# 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 +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### Rider template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + diff --git a/Server/AuthSession.cs b/Server/AuthSession.cs index df1dd71..443d3ae 100644 --- a/Server/AuthSession.cs +++ b/Server/AuthSession.cs @@ -1,3 +1,5 @@ +using Wonderking.Packets; + namespace Server; using System.Reflection; diff --git a/Server/Dockerfile b/Server/Dockerfile index 5bcbaf6..709b557 100644 --- a/Server/Dockerfile +++ b/Server/Dockerfile @@ -1,18 +1,28 @@ -FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base +FROM mcr.microsoft.com/dotnet/runtime:8.0-bookworm-slim AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build +ARG TARGETARCH +ENV TZ=Etc/UTC +ENV DOTNET_TieredPGO=1 +ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 + +RUN echo "Target: $TARGETARCH" +RUN echo "Build: $BUILDPLATFORM" WORKDIR /src +COPY ["Wonderking/Wonderking.csproj", "Wonderking/"] COPY ["Server/Server.csproj", "Server/"] -RUN dotnet restore "Server/Server.csproj" +RUN dotnet restore "Wonderking/Wonderking.csproj" -a $TARGETARCH +RUN dotnet restore "Server/Server.csproj" -a $TARGETARCH COPY . . -WORKDIR "/src/Server" -RUN dotnet build "Server.csproj" -c Release -o /app/build FROM build AS publish -RUN dotnet publish "Server.csproj" -c Release -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Server/Server.csproj" -c Release -a $TARGETARCH --no-restore -f net8.0 -o /app FROM base AS final WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Server.dll"] +COPY --from=publish /app . +USER $APP_UID +ENTRYPOINT ["./Server"] + + diff --git a/Server/LoggerMessages/PacketLoggerMessages.cs b/Server/LoggerMessages/PacketLoggerMessages.cs index 0654492..3601281 100644 --- a/Server/LoggerMessages/PacketLoggerMessages.cs +++ b/Server/LoggerMessages/PacketLoggerMessages.cs @@ -1,8 +1,8 @@ -namespace Server; - using JetBrains.Annotations; using Microsoft.Extensions.Logging; -using Packets; +using Wonderking.Packets; + +namespace Server.LoggerMessages; public static partial class PacketLoggerMessages { diff --git a/Server/PacketHandlers/ChannelSelectionHandler.cs b/Server/PacketHandlers/ChannelSelectionHandler.cs index 3db2358..12c2030 100644 --- a/Server/PacketHandlers/ChannelSelectionHandler.cs +++ b/Server/PacketHandlers/ChannelSelectionHandler.cs @@ -1,10 +1,12 @@ +using Microsoft.EntityFrameworkCore; +using Wonderking.Packets.Incoming; + namespace Server.PacketHandlers; using DB; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NetCoreServer; -using Packets.Incoming; public class ChannelSelectionHandler : IPacketHandler { @@ -27,7 +29,9 @@ public class ChannelSelectionHandler : IPacketHandler public Task HandleAsync(ChannelSelectionPacket packet, TcpSession session) { var authSession = (AuthSession)session; - var charactersOfAccount = this._wonderkingContext.Accounts.FirstOrDefault(a => a.Id == authSession.AccountId); + var charactersOfAccount = this._wonderkingContext.Accounts.Include(account => account.Characters) + .FirstOrDefault(a => a.Id == authSession.AccountId) + ?.Characters; return Task.CompletedTask; } } diff --git a/Server/PacketHandlers/IPacketHandler.cs b/Server/PacketHandlers/IPacketHandler.cs index a9f1c86..40448d6 100644 --- a/Server/PacketHandlers/IPacketHandler.cs +++ b/Server/PacketHandlers/IPacketHandler.cs @@ -1,8 +1,9 @@ +using Wonderking.Packets; + namespace Server.PacketHandlers; using JetBrains.Annotations; using NetCoreServer; -using Packets; [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] public interface IPacketHandler where T : IPacket diff --git a/Server/PacketHandlers/LoginHandler.cs b/Server/PacketHandlers/LoginHandler.cs index 3955229..35dd997 100644 --- a/Server/PacketHandlers/LoginHandler.cs +++ b/Server/PacketHandlers/LoginHandler.cs @@ -1,15 +1,16 @@ -namespace Server.PacketHandlers; - using System.Security.Cryptography; using System.Text; +using Wonderking.Packets.Incoming; +using Wonderking.Packets.Outgoing; + +namespace Server.PacketHandlers; + using DB; using DB.Documents; using Konscious.Security.Cryptography; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NetCoreServer; -using Packets.Incoming; -using Packets.Outgoing; public class LoginHandler : IPacketHandler { @@ -78,12 +79,9 @@ public class LoginHandler : IPacketHandler IsGameMaster = true }; var sess = session as AuthSession; - if (account != null) + if (account != null && sess != null) { - if (sess != null) - { - sess.AccountId = account.Id; - } + sess.AccountId = account.Id; } sess?.Send(loginResponsePacket); diff --git a/Server/Packets/RawPacket.cs b/Server/Packets/RawPacket.cs index 6f96690..11e7ca0 100644 --- a/Server/Packets/RawPacket.cs +++ b/Server/Packets/RawPacket.cs @@ -1,3 +1,5 @@ +using Wonderking.Packets; + namespace Server.Packets; using MassTransit; diff --git a/Server/Server.csproj b/Server/Server.csproj index bd69f41..cfa8679 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -2,13 +2,32 @@ Exe - net7.0 enable warnings Linux Server default true + net8.0;net7.0 + true + strict + Timothy (RaiNote) Schenk + Timothy (RaiNote) Schenk + https://forge.rainote.dev/wonderking/continuity + https://forge.rainote.dev/wonderking/continuity + git + False + True + LICENSE + latest-recommended + + + + 7 + + + + 7 @@ -18,26 +37,35 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + @@ -45,6 +73,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -57,10 +89,6 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -68,4 +96,15 @@ Always + + + + True + \ + + + + + + diff --git a/Server/Services/PacketDistributorService.cs b/Server/Services/PacketDistributorService.cs index 28cbae4..79f9c34 100644 --- a/Server/Services/PacketDistributorService.cs +++ b/Server/Services/PacketDistributorService.cs @@ -1,3 +1,6 @@ +using Server.LoggerMessages; +using Wonderking.Packets; + namespace Server.Services; using System.Collections.Concurrent; @@ -26,13 +29,10 @@ public class PacketDistributorService : IHostedService private readonly ILogger _logger; private readonly ConcurrentDictionary _packetHandlersInstantiation; - private readonly IServiceProvider _serviceProvider; - public PacketDistributorService(ILogger logger, IServiceProvider serviceProvider) { this._concurrentQueue = new ConcurrentQueue(); this._logger = logger; - this._serviceProvider = serviceProvider; var tempDeserializationMap = new Dictionary>(); @@ -43,7 +43,7 @@ public class PacketDistributorService : IHostedService packetHandlers.ForEach(x => { var packetHandler = - ActivatorUtilities.GetServiceOrCreateInstance(this._serviceProvider, + ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider, x.Value); this._packetHandlersInstantiation.TryAdd(x.Key, packetHandler); }); @@ -92,12 +92,24 @@ public class PacketDistributorService : IHostedService private Dictionary GetAllPacketHandlersWithId(Assembly assembly) { - var packetHandlersWithId = assembly.GetTypes().AsParallel().Where(t => - t is { IsClass: true, IsAbstract: false } && t - .GetInterfaces().Any(i => - i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))).ToDictionary(type => type.GetInterfaces().First(t => - t is { IsGenericType: true } && t.GetGenericTypeDefinition() == typeof(IPacketHandler<>)) - .GetGenericArguments().First().GetCustomAttribute().Code); + // ! : We are filtering if types that don't have an instance of the required Attribute + var packetHandlersWithId = assembly.GetTypes().AsParallel() + .Where(t => + t is { IsClass: true, IsAbstract: false } && Array.Exists(t + .GetInterfaces(), i => + i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IPacketHandler<>))) + .Select(type => new + { + Type = type, + PacketId = type + .GetInterfaces().First(t1 => + t1 is { IsGenericType: true } && t1.GetGenericTypeDefinition() == typeof(IPacketHandler<>)) + .GetGenericArguments()[0].GetCustomAttribute()?.Code + }) + .Where(x => x.PacketId is not null) + .ToDictionary( + x => x.PacketId!.Value, x => x.Type + ); if (packetHandlersWithId is not { Count: 0 }) { @@ -136,7 +148,8 @@ public class PacketDistributorService : IHostedService var packet = value(item.MessageBody); this._logger.PacketData(JsonConvert.SerializeObject(packet)); - this._packetHandlersInstantiation[item.OperationCode].GetType().GetMethod(nameof(IPacketHandler.HandleAsync)) + this._packetHandlersInstantiation[item.OperationCode].GetType() + .GetMethod(nameof(IPacketHandler.HandleAsync)) ?.Invoke(this._packetHandlersInstantiation[item.OperationCode], new object[] { packet, item.Session }); this._logger.PacketFinished(item.Session.Id, item.OperationCode); diff --git a/Server/docker-compose.yml b/Server/docker-compose.yml index 5cbd3e9..1efa332 100644 --- a/Server/docker-compose.yml +++ b/Server/docker-compose.yml @@ -1,6 +1,9 @@ services: server: - image: continuity-server:latest + container_name: continuity-server + image: server:latest + depends_on: + - db environment: - ENVIRONMENT=Development - Testing:CreateAccountOnLogin=true @@ -14,6 +17,7 @@ - "10001:10001" db: + container_name: continuity-db image: postgres:16.0-alpine environment: - POSTGRES_USER=continuity @@ -23,6 +27,11 @@ - continuity volumes: - db-data:/var/lib/postgresql/data + healthcheck: + test: [ "CMD-SHELL", "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'" ] + interval: 10s + timeout: 3s + retries: 3 networks: continuity: diff --git a/Server/Packets/IPacket.cs b/Wonderking/Packets/IPacket.cs similarity index 86% rename from Server/Packets/IPacket.cs rename to Wonderking/Packets/IPacket.cs index e5d5317..fa795eb 100644 --- a/Server/Packets/IPacket.cs +++ b/Wonderking/Packets/IPacket.cs @@ -1,7 +1,7 @@ -namespace Server.Packets; - using JetBrains.Annotations; +namespace Wonderking.Packets; + [UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)] public interface IPacket { diff --git a/Server/Packets/Incoming/ChannelSelectionPacket.cs b/Wonderking/Packets/Incoming/ChannelSelectionPacket.cs similarity index 77% rename from Server/Packets/Incoming/ChannelSelectionPacket.cs rename to Wonderking/Packets/Incoming/ChannelSelectionPacket.cs index ea17fb4..c74e385 100644 --- a/Server/Packets/Incoming/ChannelSelectionPacket.cs +++ b/Wonderking/Packets/Incoming/ChannelSelectionPacket.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Incoming; +namespace Wonderking.Packets.Incoming; [PacketId(OperationCode.ChannelSelection)] public class ChannelSelectionPacket : IPacket @@ -12,5 +12,5 @@ public class ChannelSelectionPacket : IPacket this.ChannelId = BitConverter.ToUInt16(data, 2); } - public byte[] Serialize() => throw new NotImplementedException(); + public byte[] Serialize() => throw new NotSupportedException(); } diff --git a/Server/Packets/Incoming/LoginInfoPacket.cs b/Wonderking/Packets/Incoming/LoginInfoPacket.cs similarity index 96% rename from Server/Packets/Incoming/LoginInfoPacket.cs rename to Wonderking/Packets/Incoming/LoginInfoPacket.cs index 4351884..4758ef7 100644 --- a/Server/Packets/Incoming/LoginInfoPacket.cs +++ b/Wonderking/Packets/Incoming/LoginInfoPacket.cs @@ -1,7 +1,7 @@ -namespace Server.Packets.Incoming; - using System.Text; +namespace Wonderking.Packets.Incoming; + [PacketId(OperationCode.LoginInfo)] public class LoginInfoPacket : IPacket { diff --git a/Server/Packets/OperationCode.cs b/Wonderking/Packets/OperationCode.cs similarity index 77% rename from Server/Packets/OperationCode.cs rename to Wonderking/Packets/OperationCode.cs index 578c544..f8b9eea 100644 --- a/Server/Packets/OperationCode.cs +++ b/Wonderking/Packets/OperationCode.cs @@ -1,4 +1,4 @@ -namespace Server.Packets; +namespace Wonderking.Packets; public enum OperationCode : ushort { diff --git a/Server/Packets/Outgoing/LoginResponsePacket.cs b/Wonderking/Packets/Outgoing/LoginResponsePacket.cs similarity index 98% rename from Server/Packets/Outgoing/LoginResponsePacket.cs rename to Wonderking/Packets/Outgoing/LoginResponsePacket.cs index 63299fe..057d032 100644 --- a/Server/Packets/Outgoing/LoginResponsePacket.cs +++ b/Wonderking/Packets/Outgoing/LoginResponsePacket.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Outgoing; +namespace Wonderking.Packets.Outgoing; [PacketId(OperationCode.LoginResponse)] public class LoginResponsePacket : IPacket diff --git a/Server/Packets/Outgoing/LoginResponseReason.cs b/Wonderking/Packets/Outgoing/LoginResponseReason.cs similarity index 92% rename from Server/Packets/Outgoing/LoginResponseReason.cs rename to Wonderking/Packets/Outgoing/LoginResponseReason.cs index b4e8bff..adc830f 100644 --- a/Server/Packets/Outgoing/LoginResponseReason.cs +++ b/Wonderking/Packets/Outgoing/LoginResponseReason.cs @@ -1,4 +1,4 @@ -namespace Server.Packets.Outgoing; +namespace Wonderking.Packets.Outgoing; public enum LoginResponseReason : byte { diff --git a/Server/Packets/Outgoing/ServerChannelData.cs b/Wonderking/Packets/Outgoing/ServerChannelData.cs similarity index 60% rename from Server/Packets/Outgoing/ServerChannelData.cs rename to Wonderking/Packets/Outgoing/ServerChannelData.cs index a6eee00..b707c4a 100644 --- a/Server/Packets/Outgoing/ServerChannelData.cs +++ b/Wonderking/Packets/Outgoing/ServerChannelData.cs @@ -1,5 +1,8 @@ -namespace Server.Packets.Outgoing; +using System.Runtime.InteropServices; +namespace Wonderking.Packets.Outgoing; + +[StructLayout(LayoutKind.Auto)] public struct ServerChannelData { public ushort ServerId { get; set; } diff --git a/Server/Packets/PacketIdAttribute.cs b/Wonderking/Packets/PacketIdAttribute.cs similarity index 87% rename from Server/Packets/PacketIdAttribute.cs rename to Wonderking/Packets/PacketIdAttribute.cs index 6638733..e2f2b5a 100644 --- a/Server/Packets/PacketIdAttribute.cs +++ b/Wonderking/Packets/PacketIdAttribute.cs @@ -1,4 +1,4 @@ -namespace Server.Packets; +namespace Wonderking.Packets; [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class PacketIdAttribute : Attribute diff --git a/Wonderking/Wonderking.csproj b/Wonderking/Wonderking.csproj new file mode 100644 index 0000000..e8fbd2c --- /dev/null +++ b/Wonderking/Wonderking.csproj @@ -0,0 +1,34 @@ + + + + enable + enable + net8.0;net7.0 + strict + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/build.cmd b/build.cmd deleted file mode 100644 index b08cc59..0000000 --- a/build.cmd +++ /dev/null @@ -1,7 +0,0 @@ -:; set -eo pipefail -:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) -:; ${SCRIPT_DIR}/build.sh "$@" -:; exit $? - -@ECHO OFF -powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 2719418..0000000 --- a/build.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -[CmdletBinding()] -Param( - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$BuildArguments -) - -Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" - -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } -$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent - -########################################################################### -# CONFIGURATION -########################################################################### - -$BuildProjectFile = "$PSScriptRoot\build\build.csproj" -$TempDirectory = "$PSScriptRoot\\.nuke\temp" - -$DotNetGlobalFile = "$PSScriptRoot\\global.json" -$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" -$DotNetChannel = "STS" - -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:DOTNET_MULTILEVEL_LOOKUP = 0 - -########################################################################### -# EXECUTION -########################################################################### - -function ExecSafe([scriptblock] $cmd) { - & $cmd - if ($LASTEXITCODE) { exit $LASTEXITCODE } -} - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` - $(dotnet --version) -and $LASTEXITCODE -eq 0) { - $env:DOTNET_EXE = (Get-Command "dotnet").Path -} -else { - # Download install script - $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) - - # If global.json exists, load expected version - if (Test-Path $DotNetGlobalFile) { - $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) - if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { - $DotNetVersion = $DotNetGlobal.sdk.version - } - } - - # Install by channel or version - $DotNetDirectory = "$TempDirectory\dotnet-win" - if (!(Test-Path variable:DotNetVersion)) { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } - } else { - ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } - } - $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" -} - -Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)" - -if (Test-Path env:NUKE_ENTERPRISE_TOKEN) { - & $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null - & $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null -} - -ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } -ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh deleted file mode 100644 index 25e0d46..0000000 --- a/build.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -bash --version 2>&1 | head -n 1 - -set -eo pipefail -SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) - -########################################################################### -# CONFIGURATION -########################################################################### -BUILD_PROJECT_FILE="$SCRIPT_DIR/build/build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" - -DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" -DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" -DOTNET_CHANNEL="STS" - -export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export DOTNET_MULTILEVEL_LOOKUP=0 - -########################################################################### -# EXECUTION -########################################################################### - -function FirstJsonValue { - perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" -} - -# If dotnet CLI is installed globally and it matches requested version, use for execution -if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then - export DOTNET_EXE="$(command -v dotnet)" -else - # Download install script - DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" - mkdir -p "$TEMP_DIRECTORY" - curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" - chmod +x "$DOTNET_INSTALL_FILE" - - # If global.json exists, load expected version - if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then - DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") - if [[ "$DOTNET_VERSION" == "" ]]; then - unset DOTNET_VERSION - fi - fi - - # Install by channel or version - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - if [[ -z ${DOTNET_VERSION+x} ]]; then - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path - else - "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path - fi - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" -fi - -echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)" - -if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then - "$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true - "$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true -fi - -"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet -"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/global.json b/global.json index 37704f0..ad3eb2c 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "7.0.0", + "version": "7.0.403", "rollForward": "latestMajor", "allowPrerelease": true } -} +} \ No newline at end of file