Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Apply Zeya fixers #1

Merged
merged 2 commits into from
Mar 1, 2024
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
44 changes: 44 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build and test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ '*' ]


env:
working-directory: Sources
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
dotnet-version: 8.0.x

jobs:
build:
runs-on: ubuntu-latest

steps:
- run: git config --global core.autocrlf input
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.dotnet-version }}

- name: Restore dependencies
run: dotnet restore
working-directory: ${{ env.working-directory }}

- name: Build
run: dotnet build -c Release --no-restore --verbosity normal
working-directory: ${{ env.working-directory }}

- name: Test
run: dotnet test -c Release --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
working-directory: ${{ env.working-directory }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
40 changes: 40 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Project Mesty

Mesty is PoC of tooling that try to calculate all possible states of code that executes by multiple threads.

For example, this code:

```csharp
public class SampleClass1
{
private long _setCount;
private readonly AutoResetEvent _notEmptyEvent = new(false);

public void Set()
{
long newValue;
newValue = Interlocked.Increment(ref _setCount);
long tempValue = 1;
if (newValue == tempValue)
{
_notEmptyEvent.Set();
}
}
}
```

can be invoked this way:

```csharp
for (int i = 0; i < 3; i++)
Task.Run(() => classInstance.Set());
```

3 threads will try to execute `Increment` method and possible results of method class for different methods:
```
1. 1th - 1; 2th - 2; 3th - 3
2. 1th - 1; 2th - 3; 3th - 2
3. ...
```

Generating all combinations allow us to proof that code has deadlocks or lead to unexpected results.
199 changes: 103 additions & 96 deletions Sources/.editorconfig

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions Sources/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591;IDE0055</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591;IDE0055</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<UseArtifactsOutput>true</UseArtifactsOutput>
<Authors>Kysect</Authors>
<Company>Kysect</Company>
<Copyright>Copyright (c) Kysect 2024</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<DebugType>portable</DebugType>
<IncludeSymbols>true</IncludeSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Kysect.Editorconfig" />
</ItemGroup>
</Project>
33 changes: 17 additions & 16 deletions Sources/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="codeessentials.Extensions.Logging.Demystifier" Version="1.1.66" />
<PackageVersion Include="Kysect.CommonLib" Version="0.1.8" />
<PackageVersion Include="Kysect.CommonLib.DependencyInjection" Version="0.1.8" />
<PackageVersion Include="Kysect.Editorconfig" Version="1.1.4" />
<PackageVersion Include="Kysect.CommonLib" Version="0.1.18" />
<PackageVersion Include="Kysect.CommonLib.DependencyInjection" Version="0.1.18" />
<PackageVersion Include="Kysect.Editorconfig" Version="1.1.8" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="FluentAssertions" Version="[6.12.0, )" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="NUnit.Analyzers" Version="3.6.1" />
<PackageVersion Include="NUnit.Analyzers" Version="3.10.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Kysect.Editorconfig" Version="1.1.8" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions Sources/Kysect.Mesty.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mesty.SourceCodeDeclaration
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mesty.Tests", "Mesty.Tests\Mesty.Tests.csproj", "{8D85B125-AE53-4494-BB8D-E67489581FCC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FC6D15CD-6B2C-4D33-B67B-550DEA4A1920}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
6 changes: 1 addition & 5 deletions Sources/Mesty.Core/Mesty.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.CommonLib" />
<PackageReference Include="Kysect.Editorconfig" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions Sources/Mesty.Interpreter/Mesty.Interpreter.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.Editorconfig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mesty.Core\Mesty.Core.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.Abstractions\Mesty.SourceCodeDeclaration.Abstractions.csproj" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions Sources/Mesty.Playground/Mesty.Playground.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.CommonLib.DependencyInjection" />
<PackageReference Include="Kysect.Editorconfig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mesty.Interpreter\Mesty.Interpreter.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.Abstractions\Mesty.SourceCodeDeclaration.Abstractions.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.RoslynParser\Mesty.SourceCodeDeclaration.RoslynParser.csproj" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions Sources/Mesty.Playground/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Kysect.CommonLib.DependencyInjection;
using Kysect.CommonLib.DependencyInjection.Logging;
using Mesty.Interpreter;
using Mesty.Interpreter.Models;
using Mesty.SourceCodeDeclaration.Abstractions.Models;
Expand Down Expand Up @@ -26,8 +26,8 @@ public void Set()
}
}
}";
var _parser = new RoslynSourceCodeClassDeclarationParser(PredefinedLogger.CreateConsoleLogger());
var _interpreter = new SourceCodeInterpreter(PredefinedLogger.CreateConsoleLogger());
var _parser = new RoslynSourceCodeClassDeclarationParser(DefaultLoggerConfiguration.CreateConsoleLogger());
var _interpreter = new SourceCodeInterpreter(DefaultLoggerConfiguration.CreateConsoleLogger());


SourceCodeClassDeclaration sourceCodeDeclaration = _parser.Parse(code);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.CommonLib" />
<PackageReference Include="Kysect.Editorconfig" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.Editorconfig" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mesty.Core\Mesty.Core.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.Abstractions\Mesty.SourceCodeDeclaration.Abstractions.csproj" />
</ItemGroup>

</Project>
12 changes: 0 additions & 12 deletions Sources/Mesty.Tests/Mesty.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>$(NoWarn);CS1591;CA1707</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>$(NoWarn);CS1591;CA1707</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Kysect.CommonLib.DependencyInjection" />
<PackageReference Include="Kysect.Editorconfig" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
Expand All @@ -30,11 +20,9 @@
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mesty.Interpreter\Mesty.Interpreter.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.Abstractions\Mesty.SourceCodeDeclaration.Abstractions.csproj" />
<ProjectReference Include="..\Mesty.SourceCodeDeclaration.RoslynParser\Mesty.SourceCodeDeclaration.RoslynParser.csproj" />
</ItemGroup>

</Project>
9 changes: 5 additions & 4 deletions Sources/Mesty.Tests/SourceCodeContextParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Kysect.CommonLib.DependencyInjection;
using Kysect.CommonLib.DependencyInjection.Logging;
using Mesty.SourceCodeDeclaration.Abstractions.Contracts;
using Mesty.SourceCodeDeclaration.Abstractions.Models;
using Mesty.SourceCodeDeclaration.Abstractions.Models.Methods;
Expand All @@ -19,7 +19,7 @@ public class SourceCodeContextParserTests
public void Setup()
{
_executionStatementComparator = new ExecutionStatementComparator();
_parser = new RoslynSourceCodeClassDeclarationParser(PredefinedLogger.CreateConsoleLogger());
_parser = new RoslynSourceCodeClassDeclarationParser(DefaultLoggerConfiguration.CreateConsoleLogger());
}

[Test]
Expand All @@ -35,8 +35,9 @@ public void ParseGlobalContext_ShouldReturnAllClassFields()

Assert.That(sourceCodeDeclaration.TypeName, Is.EqualTo("SampleClass1"));
Assert.That(sourceCodeDeclaration.MemberVariables.Count, Is.EqualTo(2));
Assert.Contains(new SimpleLongSourceCodeVariableDeclaration("_setCount", 0), (System.Collections.ICollection)sourceCodeDeclaration.MemberVariables);
Assert.Contains(new AutoResetEventSourceCodeVariableDeclaration("_notEmptyEvent", false), (System.Collections.ICollection)sourceCodeDeclaration.MemberVariables);

Assert.That(sourceCodeDeclaration.MemberVariables, Has.Member(new SimpleLongSourceCodeVariableDeclaration("_setCount", 0)));
Assert.That(sourceCodeDeclaration.MemberVariables, Has.Member(new AutoResetEventSourceCodeVariableDeclaration("_notEmptyEvent", false)));
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions Sources/Mesty.Tests/SourceCodeInterpreterTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Kysect.CommonLib.BaseTypes.Extensions;
using Kysect.CommonLib.DependencyInjection;
using Kysect.CommonLib.DependencyInjection.Logging;
using Mesty.Interpreter;
using Mesty.Interpreter.Models;
using Mesty.SourceCodeDeclaration.Abstractions.Contracts;
Expand All @@ -21,8 +21,8 @@ public class SourceCodeInterpreterTests
public void Setup()
{
new ExecutionStatementComparator();
_parser = new RoslynSourceCodeClassDeclarationParser(PredefinedLogger.CreateConsoleLogger());
_interpreter = new SourceCodeInterpreter(PredefinedLogger.CreateConsoleLogger());
_parser = new RoslynSourceCodeClassDeclarationParser(DefaultLoggerConfiguration.CreateConsoleLogger());
_interpreter = new SourceCodeInterpreter(DefaultLoggerConfiguration.CreateConsoleLogger());
}

[Test]
Expand Down
Loading