Skip to content
Merged
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
376 changes: 341 additions & 35 deletions .editorconfig

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "12:00"
timezone: "Europe/Moscow"
open-pull-requests-limit: 10
versioning-strategy: auto
labels:
- "dependencies"
- "nuget"
commit-message:
prefix: "chore"
include: "scope"
reviewers:
- "VladislavRudakoff"
37 changes: 37 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CodeQL Analysis
on:
push:
branches: [master, main]
paths:
- '**.cs'
- '**.csproj'
pull_request:
branches: [master, main]
paths:
- '**.cs'
- '**.csproj'
schedule:
- cron: '0 12 * * 0' # Weekly on Sunday at 12:00 UTC
jobs:
analyze:
name: analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ['csharp']
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
22 changes: 22 additions & 0 deletions .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Generate Documentation
on:
push:
branches: [main]
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install DocFX
run: dotnet tool install -g docfx
- name: Build Documentation
run: docfx docfx_project/docfx.json
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docfx_project/_site
17 changes: 17 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Code Format Check
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Run dotnet format
run: dotnet format --verify-no-changes
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

husky run --group pre-commit
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

husky run --group pre-push
18 changes: 18 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
"tasks": [
{
"name": "format",
"group": "pre-commit",
"command": "dotnet",
"args": [ "format", "--verify-no-changes", "--include", "${staged}", "--exclude", "**/tests/**" ],
"include": [ "**/*.cs" ]
},
{
"name": "simple-build",
"group": "pre-push",
"command": "dotnet",
"args": [ "build" ]
}
]
}
10 changes: 10 additions & 0 deletions AlchemyLab.ToolBox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
.husky\pre-commit = .husky\pre-commit
.husky\pre-push = .husky\pre-push
.husky\task-runner.json = .husky\task-runner.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{92987ACC-7E45-4F26-99BD-C0536C242D5B}"
Expand All @@ -21,6 +24,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlchemyLab.ToolBox.AspNet",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlchemyLab.ToolBox.Decorating", "src\AlchemyLab.ToolBox.Decorating\AlchemyLab.ToolBox.Decorating.csproj", "{38931641-20F7-4068-A947-3FD7660DD5F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
ProjectSection(SolutionItems) = preProject
.github\workflows\codeql.yml = .github\workflows\codeql.yml
.github\dependabot.yml = .github\dependabot.yml
.github\workflows\format.yml = .github\workflows\format.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
6 changes: 5 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<Target Name="husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0 and '$(IsCrossTargetingBuild)' == 'true'">
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory="..\.." />
</Target>

<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.*">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.*" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions src/AlchemyLab.ToolBox.Common/ValueStopwatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ public readonly struct ValueStopwatch

private readonly long startTimestamp;

/// <summary>
/// Флаг отражающий активность таймера
/// </summary>
public bool IsActive => startTimestamp is not 0;

private ValueStopwatch(long startTimestamp) => this.startTimestamp = startTimestamp;

/// <summary>
/// Запустить новый таймер
/// </summary>
public static ValueStopwatch StartNew() => new(Stopwatch.GetTimestamp());

/// <summary>
/// Получить информацию о только сколько прошло времени
/// </summary>
public TimeSpan GetElapsedTime()
{
// Start timestamp can't be zero in an initialized ValueStopwatch. It would have to be literally the first thing executed when the machine boots to be 0.
Expand Down
Loading