Skip to content

Commit

Permalink
Update sdk to .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriktsarpalis committed Nov 19, 2023
1 parent a1f09e4 commit 3314964
Show file tree
Hide file tree
Showing 29 changed files with 123 additions and 79 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*.cs]

# CA1000: Do not declare static members on generic types
dotnet_diagnostic.CA1000.severity = none

# CA1865: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
dotnet_diagnostic.CA1865.severity = none
18 changes: 3 additions & 15 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<Project ToolsVersion="15.0">
<Project>
<PropertyGroup>
<IsPackable>false</IsPackable>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSymbols>true</IncludeSymbols>
<Company>Nessos Information Technologies</Company>
<Authors>Nessos Information Technologies</Authors>
<Owners>Nessos Information Technologies</Owners>
<RepositoryUrl>https://github.com/nessos/Eff</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Programming with effects and handlers in C#</description>
<PackageReleaseNotes>https://github.com/nessos/Eff/blob/master/CHANGELOG.md</PackageReleaseNotes>
<copyright>Copyright 2020</copyright>
<tags>C# effects handlers</tags>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
</Project>
24 changes: 24 additions & 0 deletions Directory.packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Build Infra & Packaging -->
<PackageVersion Include="PolySharp" Version="1.13.1" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageVersion Include="MinVer" Version="4.3.0" />
<!-- Testing dependencies -->
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.8" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.8" />
<!-- Samples dependencies -->
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageVersion Include="Eff" Version="2.0.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine3.14
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine

RUN apk add git make

Expand Down
10 changes: 5 additions & 5 deletions samples/Eff.Examples.AspNetCore/Eff.Examples.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<TargetFramework>net8.0</TargetFramework>
<NoWarn>CS1998;CS1591;$(NoWarn)</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<!-- Use NuGet build for easier debugging -->
<UseNugetEff>true</UseNugetEff>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Eff" Version="2.0.2" Condition="'$(UseNugetEff)' == 'True'" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Eff" Condition="'$(UseNugetEff)' == 'True'" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void WriteToAwaiter<TResult>(EffAwaiter<TResult> awaiter)
if (IsException)
{
var exn = JsonConvert.DeserializeObject<Exception>(Value);
awaiter.SetException(exn);
awaiter.SetException(exn!);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class ReplayTokenHeaderHelpers

public static void AddReplayTokenHeader(this HttpResponse response, string replayToken)
{
response.Headers.Add(EffReplayTokenHeaderName, replayToken);
response.Headers.Append(EffReplayTokenHeaderName, replayToken);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
4 changes: 2 additions & 2 deletions samples/Eff.Examples.Config/Eff.Examples.Config.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Eff.Examples.Console/Eff.Examples.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
3 changes: 1 addition & 2 deletions samples/Eff.Examples.Maybe/Eff.Examples.Maybe.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions samples/Eff.Examples.Resumable/Eff.Examples.Resumable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion samples/Eff.Examples.TraceLog/Eff.Examples.TraceLog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
29 changes: 29 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project>
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>Nullable</WarningsAsErrors>
<WarningLevel>9999</WarningLevel>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSymbols>true</IncludeSymbols>
<Company>Nessos Information Technologies</Company>
<Authors>Nessos Information Technologies</Authors>
<Owners>Nessos Information Technologies</Owners>
<RepositoryUrl>https://github.com/nessos/Eff</RepositoryUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Programming with effects and handlers in C#</description>
<PackageReleaseNotes>https://github.com/nessos/Eff/blob/master/CHANGELOG.md</PackageReleaseNotes>
<copyright>Copyright 2020</copyright>
<tags>C# effects handlers</tags>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Eff/Applications/DependencyInjection/DependencyEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class DependencyEffect<TResult> : Effect<TResult>
public abstract ValueTask<TResult> Handle(IContainer container);
}

internal class FuncDependencyEffect<TDependency, TResult> : DependencyEffect<TResult>
internal sealed class FuncDependencyEffect<TDependency, TResult> : DependencyEffect<TResult>
{
public Func<TDependency, ValueTask<TResult>> Func { get; }

Expand All @@ -31,7 +31,7 @@ public override ValueTask<TResult> Handle(IContainer container)
}
}

internal class ContainerFuncDependencyEffect<TResult> : DependencyEffect<TResult>
internal sealed class ContainerFuncDependencyEffect<TResult> : DependencyEffect<TResult>
{
public Func<IContainer, ValueTask<TResult>> Func { get; }

Expand Down
8 changes: 4 additions & 4 deletions src/Eff/Eff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<Description>Programming with effects and handlers in C#</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>10.0</LangVersion>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="2.5.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" />
<PackageReference Include="MinVer" />
<PackageReference Include="PolySharp" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Eff/Handlers/EffAwaiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal EffAwaiter() { }
/// <summary>
/// Gets or sets the line number at the source file at which the method is called.
/// </summary>
public int CallerLineNumber { get; set; } = 0;
public int CallerLineNumber { get; set; }

/// <summary>
/// Returns true if the awaiter has been completed with a result value.
Expand Down Expand Up @@ -122,7 +122,7 @@ public void GetResult()
/// <typeparam name="TResult">Result type required by the awaiter.</typeparam>
public abstract class EffAwaiter<TResult> : EffAwaiter
{
private TResult? _result = default;
private TResult? _result;

/// <summary>
/// Gets either the result value or throws the exception that have been stored in the awaiter.
Expand Down
2 changes: 1 addition & 1 deletion src/Eff/Handlers/EffectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public virtual async ValueTask Handle<TResult>(EffStateMachine<TResult> stateMac

default:
Debug.Fail($"Unrecognized state machine position {stateMachine.Position}.");
throw new Exception($"Internal error: unrecognized state machine position {stateMachine.Position}.");
throw new InvalidOperationException($"Internal error: unrecognized state machine position {stateMachine.Position}.");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Eff/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace Nessos.Effects
/// <summary>
/// Gets the Unit instance.
/// </summary>
public static Unit Value => new Unit();
public static Unit Value => new();
/// Implements unit hashcode
public override int GetHashCode() => 1;
/// Implements unit equality
public override bool Equals(object other) => other is Unit;
public override bool Equals(object? obj) => obj is Unit;
/// Implements unit equality
public bool Equals(Unit other) => true;
/// Implements unit equality
Expand Down
25 changes: 12 additions & 13 deletions src/Eff/Utils/TraceHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ private static (string name, FieldInfo fieldInfo)[] GetParametersInfo(object sta
{
var fieldInfos = state.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

var parametersInfo = fieldInfos
.Where(fieldInfo => !fieldInfo.Name.StartsWith("<"))
.Select(fieldInfo => (fieldInfo.Name, fieldInfo))
.ToArray();
return parametersInfo;
return fieldInfos
.Where(fieldInfo => !fieldInfo.Name.StartsWith("<", StringComparison.Ordinal))
.Select(fieldInfo => (fieldInfo.Name, fieldInfo))
.ToArray();
}

private static (string name, FieldInfo fieldInfo)[] GetLocalVariablesInfo(object state)
{
var fieldInfos = state.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

var localVariablesInfo = fieldInfos
.Where(fieldInfo => !fieldInfo.Name.StartsWith("<>"))
.Where(fieldInfo => fieldInfo.Name.StartsWith("<"))
.Select(fieldInfo => (fieldInfo.Name.Substring(1, fieldInfo.Name.LastIndexOf(">") - 1), fieldInfo))
.ToArray();
return localVariablesInfo;
return fieldInfos
.Where(fieldInfo => !fieldInfo.Name.StartsWith("<>", StringComparison.Ordinal))
.Where(fieldInfo => fieldInfo.Name.StartsWith("<", StringComparison.Ordinal))
.Select(fieldInfo => (fieldInfo.Name[1..fieldInfo.Name.LastIndexOf('>')], fieldInfo))
.ToArray();
}

/// <summary>
Expand Down Expand Up @@ -95,8 +94,8 @@ public static string GetMethodName(this IAsyncStateMachine stateMachine)
}

var name = stateMachine.GetType().Name;
if (name.StartsWith("<"))
return name.Substring(1, name.LastIndexOf(">") - 1);
if (name.StartsWith("<", StringComparison.Ordinal))
return name[1..name.LastIndexOf('>')];
else
return name;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Eff/Utils/ValueTaskPromise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ private struct ContinuationContext
public object? Scheduler;
}

private volatile int _isTaskCompleted = 0;
private volatile int _subscriptionsInProgress = 0;
private volatile int _isFirstContinuationQueued = 0;
private ContinuationContext _firstContinuation = default;
private volatile int _isTaskCompleted;
private volatile int _subscriptionsInProgress;
private volatile int _isFirstContinuationQueued;
private ContinuationContext _firstContinuation;
private ConcurrentQueue<ContinuationContext>? _additionalContinuations;

public ValueTask Task => new ValueTask(this, 0);
Expand Down
Loading

0 comments on commit 3314964

Please sign in to comment.