Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.27.3",
"commands": [
"dotnet-csharpier"
]
}
}
}
91 changes: 91 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '27 4 * * 1'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: csharp
build-mode: autobuild
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
#- if: matrix.build-mode == 'manual'
# run: |
# echo 'If you are using a "manual" build mode for one or more of the' \
# 'languages you are analyzing, replace this with the commands to build' \
# 'your code, for example:'
# echo ' make bootstrap'
# echo ' make release'
# exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
4 changes: 3 additions & 1 deletion .github/workflows/publish-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: dotnet/nbgv@master
with:
setAllVars: true
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v3
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"[csharp]": {
"editor.defaultFormatter": "csharpier.csharpier-vscode"
}
}
19 changes: 19 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<Features>strict</Features>
<ImplicitUsings>false</ImplicitUsings>

<RepositoryUrl>https://github.com/ArcadeArchie/ArcadePointsBot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Authors>ArcadeArchie</Authors>
<Copyright>Copyright 2024 ArcadeArchie</Copyright>
</PropertyGroup>

<PropertyGroup>
<DotNetVersion>8.0.0</DotNetVersion>
</PropertyGroup>
</Project>
60 changes: 60 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>


<ItemGroup>
<!-- .NET Host libs -->
<FrameworkReference Include="Microsoft.AspNetCore.App"></FrameworkReference>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>

<!-- Avalonia -->
<PackageVersion Include="Avalonia" Version="11.1.0-beta1" />
<PackageVersion Include="Avalonia.Desktop" Version="11.1.0-beta1" />
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.1.0-beta1" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.1.0-beta1" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.1.0-beta1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageVersion Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0-beta1" />
<PackageVersion Include="Avalonia.Xaml.Behaviors" Version="11.0.10.2" />
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.1.0-beta1" />
<PackageVersion Include="ReactiveUI" Version="19.6.1" />
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageVersion Include="System.Reactive" Version="6.0.0" />

<!-- Twitch Libs-->
<PackageVersion Include="TwitchLib.Api" Version="3.9.0" />
<PackageVersion Include="TwitchLib.PubSub" Version="3.2.6" />

<!-- Logging -->
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageVersion Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageVersion Include="Serilog.Sinks.File" Version="5.0.0" />

<!-- Build -->
<GlobalPackageReference Include="CSharpier.MsBuild" Version="0.27.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</GlobalPackageReference>
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.1.1" />

<!-- Other Libs -->
<PackageVersion Include="IdentityModel.OidcClient" Version="5.2.1" />
<PackageVersion Include="Mediator.Abstractions" Version="3.0.0-preview.21" />
<PackageVersion Include="Mediator.SourceGenerator" Version="3.0.0-preview.21">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
<PackageVersion Include="CliWrap" Version="3.6.6" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ CancellationToken cancellationToken
{
x.IsEnabled = false;
return x;
}).ToList();
})
.ToList();
await _rewardService.BulkUpdateRewards(
toDisable,
u => u.SetProperty(p => p.IsEnabled, false)
Expand Down
53 changes: 25 additions & 28 deletions src/ArcadePointsBot/ArcadePointsBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
Expand All @@ -16,40 +15,38 @@
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App"></FrameworkReference>
<PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" />
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Avalonia.ReactiveUI" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Fonts.Inter" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.2" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
<PackageReference Include="IdentityModel.OidcClient" Version="5.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="ReactiveUI" Version="19.5.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.1" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="TwitchLib.Api" Version="3.9.0" />
<PackageReference Include="TwitchLib.PubSub" Version="3.2.6" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" />
<PackageReference Include="Avalonia.Xaml.Behaviors" />
<PackageReference Include="Avalonia.Controls.DataGrid" />
<PackageReference Include="IdentityModel.OidcClient" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="ReactiveUI" />
<PackageReference Include="ReactiveUI.Fody" />
<PackageReference Include="System.Reactive" />
<PackageReference Include="TwitchLib.Api" />
<PackageReference Include="TwitchLib.PubSub" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Mediator.Abstractions" Version="3.0.0-preview.21" />
<PackageReference Include="Mediator.SourceGenerator" Version="3.0.0-preview.21">
<PackageReference Include="Mediator.Abstractions" />
<PackageReference Include="Mediator.SourceGenerator" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="CliWrap" Version="3.6.6" />
<PackageReference Include="CliWrap" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/ArcadePointsBot/Common/Abstractions/Messaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace ArcadePointsBot.Common.Abstractions.Messaging;

internal interface ICommand<out TResponse> : Mediator.ICommand<TResponse>
where TResponse : Result;

internal interface IQuery<TResponse> : Mediator.IQuery<TResponse>
where TResponse : Result;

Expand All @@ -21,6 +22,7 @@ internal interface IQueryHandler<in TQuery, TResponse> : Mediator.IQueryHandler<
/// </summary>
/// <typeparam name="TQuery">The query type.</typeparam>
/// <typeparam name="TResponse">The query response type.</typeparam>
internal interface ICommandHandler<in TCommand, TResponse> : Mediator.ICommandHandler<TCommand, TResponse>
internal interface ICommandHandler<in TCommand, TResponse>
: Mediator.ICommandHandler<TCommand, TResponse>
where TCommand : ICommand<TResponse>
where TResponse : Result;
where TResponse : Result;
29 changes: 17 additions & 12 deletions src/ArcadePointsBot/Common/Errors/TwitchAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ namespace ArcadePointsBot.Errors
{
public static class TwitchAPI
{
public static Error BadCredentials => new(
"TTV.API.BadCreds",
"The Credentials are invalid, resetting them and restarting the bot is recommended");
public static Error BadRewardTitle => new(
"TTV.API.BadTitle",
"The Reward Title was disallowed by twitch, try a differend one");
public static Error DupeRewardTitle => new(
"TTV.API.DupeTitle",
"The Reward with this title already exists, try a differend one or delete the duplicate");
public static Error BadCredentials =>
new(
"TTV.API.BadCreds",
"The Credentials are invalid, resetting them and restarting the bot is recommended"
);
public static Error BadRewardTitle =>
new(
"TTV.API.BadTitle",
"The Reward Title was disallowed by twitch, try a differend one"
);
public static Error DupeRewardTitle =>
new(
"TTV.API.DupeTitle",
"The Reward with this title already exists, try a differend one or delete the duplicate"
);
}

public static class Database
{
public static Error NotFound => new(
"DB.404",
"Entry not found in the database");
public static Error NotFound => new("DB.404", "Entry not found in the database");
}
}
5 changes: 2 additions & 3 deletions src/ArcadePointsBot/Common/Primitives/Result/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ protected Result(bool isSuccess, Error error)
/// <param name="error">The error in case the value is null.</param>
/// <returns>A new instance of <see cref="Result{TValue}"/> with the specified value or an error.</returns>
public static Result<TValue> Create<TValue>(TValue? value, Error error)
where TValue : class
=> value is null ? Failure<TValue>(error) : Success(value);
where TValue : class => value is null ? Failure<TValue>(error) : Success(value);

/// <summary>
/// Returns a failure <see cref="Result"/> with the specified error.
Expand Down Expand Up @@ -107,4 +106,4 @@ public static Result FirstFailureOrSuccess(params Result[] results)

return Success();
}
}
}
Loading