Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .Net 8.0 #57

Merged
merged 4 commits into from
Jan 29, 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
16 changes: 8 additions & 8 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore
- name: Build
Expand All @@ -38,30 +38,30 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
dotnet-version: 8.0.100
- name: Install dependencies ${{ matrix.test_path }}
run: dotnet restore ${{ matrix.test_path }}
- name: Build ${{ matrix.test_path }}
run: dotnet build ${{ matrix.test_path }} --configuration Release --no-restore
- name: Test Coverage ${{ matrix.test_path }}
run: dotnet test ${{ matrix.test_path }} --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Moving test results
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.info ${{ matrix.test_path }}/TestResults/coverage.info
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.cobertura.xml ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
- name: Send to coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ matrix.test_path }}/TestResults/coverage.info
file: ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
format: cobertura
flag-name: test-${{ matrix.test_path }}
parallel: true


end-coverage-ci:
needs: coverage-ci
runs-on: ubuntu-latest
steps:
- name: Finish coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore
- name: Build
Expand All @@ -38,30 +38,32 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.100
dotnet-version: 8.0.100
- name: Install dependencies ${{ matrix.test_path }}
run: dotnet restore ${{ matrix.test_path }}
- name: Build ${{ matrix.test_path }}
run: dotnet build ${{ matrix.test_path }} --configuration Release --no-restore
- name: Test Coverage ${{ matrix.test_path }}
run: dotnet test ${{ matrix.test_path }} --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Moving test results
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.info ${{ matrix.test_path }}/TestResults/coverage.info
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.cobertura.xml ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
- name: Send to coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ matrix.test_path }}/TestResults/coverage.info
file: ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
format: cobertura
flag-name: test-${{ matrix.test_path }}
parallel: true

debug: true

end-coverage-pr:
needs: coverage-pr
runs-on: ubuntu-latest
steps:
- name: Finish coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
debug: true
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ You can checkout this Github repository or you can use the NuGet package:

**Install using the command line from the Package Manager:**
```bash
Install-Package SoloX.GeneratorTools.Core.CSharp -version 1.0.0-alpha.35
Install-Package SoloX.GeneratorTools.Core.CSharp -version 1.0.0-alpha.36
```

**Install using the .Net CLI:**
```bash
dotnet add package SoloX.GeneratorTools.Core.CSharp --version 1.0.0-alpha.35
dotnet add package SoloX.GeneratorTools.Core.CSharp --version 1.0.0-alpha.36
```

**Install editing your project file (csproj):**
```xml
<PackageReference Include="SoloX.GeneratorTools.Core.CSharp" Version="1.0.0-alpha.35" />
<PackageReference Include="SoloX.GeneratorTools.Core.CSharp" Version="1.0.0-alpha.36" />
```

## The use case
Expand Down
8 changes: 4 additions & 4 deletions coverlet.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>lcov</Format>
<format>cobertura</format>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>
<UseSourceLink>false</UseSourceLink>
<IncludeTestAssembly>false</IncludeTestAssembly>
<SkipAutoProps>true</SkipAutoProps>
<DeterministicReport>false</DeterministicReport>
<Exclude>[SoloX.*.UTest]*,[SoloX.*.ITest]*,[SoloX.GeneratorTools.Core.Test.Helpers]*</Exclude>
<DeterministicReport>true</DeterministicReport>
<Exclude>[SoloX.*.UTest]*,[SoloX.*.ITest]*,[SoloX.GeneratorTools.Core.Test.Helpers]*</Exclude>
</Configuration>
</DataCollector>
</DataCollectors>
Expand Down
2 changes: 1 addition & 1 deletion src/SharedProperties.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<Version>1.0.0-alpha.35</Version>
<Version>1.0.0-alpha.36</Version>
<Authors>Xavier Solau</Authors>
<Copyright>Copyright © 2021 Xavier Solau</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.0.16">
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.0.16">
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

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

<ItemGroup>
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.0.16">
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.0.16">
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.0.16">
<PackageReference Include="SoloX.CodeQuality.Prod" Version="2.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}

/// <inheritdoc/>
public override T? VisitInterpolatedStringExpression(InterpolatedStringExpressionSyntax node)

Check warning on line 87 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / build-pr

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 87 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var strConstEval = new ConstantExpressionSyntaxEvaluator<string>(this.resolver, this.genericDeclaration);

Expand All @@ -99,19 +99,19 @@
}

/// <inheritdoc/>
public override T? VisitInterpolatedStringText(InterpolatedStringTextSyntax node)

Check warning on line 102 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / build-pr

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 102 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
return ConvertToT(node.TextToken.Text);
}

/// <inheritdoc/>
public override T? VisitInterpolation(InterpolationSyntax node)

Check warning on line 108 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / build-pr

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 108 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
return Visit(node.Expression);
}

/// <inheritdoc/>
public override T? VisitIdentifierName(IdentifierNameSyntax node)

Check warning on line 114 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var identifier = node.Identifier.ValueText;

Expand All @@ -123,7 +123,7 @@
}

/// <inheritdoc/>
public override T? VisitMemberAccessExpression(MemberAccessExpressionSyntax node)

Check warning on line 126 in src/libs/SoloX.GeneratorTools.Core.CSharp/Generator/Evaluator/ConstantExpressionSyntaxEvaluator.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (node.Expression is IdentifierNameSyntax identifier)
{
Expand Down Expand Up @@ -170,7 +170,7 @@
}
#pragma warning restore CA1062 // Valider les arguments de méthodes publiques

private static readonly IReadOnlyDictionary<string, Type> PredefinedTypeMap =
private static readonly Dictionary<string, Type> PredefinedTypeMap =
new Dictionary<string, Type>
{
["string"] = typeof(string),
Expand All @@ -182,7 +182,7 @@
["object"] = typeof(object),
};

private static readonly IReadOnlyDictionary<Type, Func<ConstantExpressionSyntaxEvaluator<T>, InitializerExpressionSyntax, T>> TypeToLoaderMap =
private static readonly Dictionary<Type, Func<ConstantExpressionSyntaxEvaluator<T>, InitializerExpressionSyntax, T>> TypeToLoaderMap =
new Dictionary<Type, Func<ConstantExpressionSyntaxEvaluator<T>, InitializerExpressionSyntax, T>>
{
[typeof(string)] = (l, i) => l.LoadArray<string>(i),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public IEnumerable<IGeneratedItem> Generate(IEnumerable<ICSharpFile> files)

generatorWalker.Visit(this.pattern.SyntaxNodeProvider.SyntaxNode.SyntaxTree.GetRoot());
});

generatedItems.Add(new GeneratedItem
{
Name = implName,
Namespace = nameSpace,
});
}
}
else
Expand All @@ -147,7 +153,9 @@ public IEnumerable<IGeneratedItem> Generate(IEnumerable<ICSharpFile> files)
this.ignoreUsingList,
this.selectorResolver);

this.writer.Generate(location, strategy.ComputeTargetName(), writer =>
var implName = strategy.ComputeTargetName();

this.writer.Generate(location, implName, writer =>
{
var generatorWalker = new AutomatedWalker(
writer,
Expand All @@ -156,6 +164,12 @@ public IEnumerable<IGeneratedItem> Generate(IEnumerable<ICSharpFile> files)

generatorWalker.Visit(this.pattern.SyntaxNodeProvider.SyntaxNode.SyntaxTree.GetRoot());
});

generatedItems.Add(new GeneratedItem
{
Name = implName,
Namespace = nameSpace,
});
}

return generatedItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class DefaultSelectorResolver : ISelectorResolver
typeof(AllSelector),
};

private readonly IReadOnlyDictionary<string, Type> typesByFullName;
private readonly IReadOnlyDictionary<string, Type> typesByName;
private readonly Dictionary<string, Type> typesByFullName;
private readonly Dictionary<string, Type> typesByName;

/// <summary>
/// Setup instance with the given types to be resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// </copyright>
// ----------------------------------------------------------------------

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SoloX.GeneratorTools.Core.CSharp.Model.Use;

namespace SoloX.GeneratorTools.Core.CSharp.Model
{
Expand All @@ -15,5 +17,9 @@
/// </summary>
public interface IEnumDeclaration : IDeclaration<EnumDeclarationSyntax>
{
/// <summary>
/// Gets the underlying type. (default is int)
/// </summary>
IDeclarationUse<SyntaxNode>? UnderlyingType { get; }

Check warning on line 23 in src/libs/SoloX.GeneratorTools.Core.CSharp/Model/IEnumDeclaration.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.UTest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 23 in src/libs/SoloX.GeneratorTools.Core.CSharp/Model/IEnumDeclaration.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tests/SoloX.GeneratorTools.Core.CSharp.ITest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 23 in src/libs/SoloX.GeneratorTools.Core.CSharp/Model/IEnumDeclaration.cs

View workflow job for this annotation

GitHub Actions / coverage-pr (src/tools.tests/SoloX.GeneratorTools.Generator.ITest)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public IReadOnlyCollection<IConstantDeclaration> Constants
/// <inheritdoc/>
public override string ToString()
{
if (this.Extends?.Any() ?? false)
if (this.Extends?.Count > 0)
{
return $"{base.ToString()}: {string.Join(", ", this.Extends?.Select(e => e.ToString()))}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
// </copyright>
// ----------------------------------------------------------------------

using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SoloX.GeneratorTools.Core.CSharp.Model.Impl.Loader;
using SoloX.GeneratorTools.Core.CSharp.Model.Resolver;
using SoloX.GeneratorTools.Core.CSharp.Model.Use;

namespace SoloX.GeneratorTools.Core.CSharp.Model.Impl
{
Expand All @@ -16,6 +19,8 @@ namespace SoloX.GeneratorTools.Core.CSharp.Model.Impl
/// </summary>
public class EnumDeclaration : ADeclaration<EnumDeclarationSyntax>, IEnumDeclaration
{
private readonly AEnumDeclarationLoader loader;

/// <summary>
/// Initializes a new instance of the <see cref="EnumDeclaration"/> class.
/// </summary>
Expand All @@ -24,20 +29,26 @@ public class EnumDeclaration : ADeclaration<EnumDeclarationSyntax>, IEnumDeclara
/// <param name="syntaxNodeProvider">The declaration syntax node provider.</param>
/// <param name="usingDirectives">The current using directive available for this enum.</param>
/// <param name="location">The location of the declaration.</param>
/// <param name="loader">The loader to use when deep loading the declaration.</param>
public EnumDeclaration(
string nameSpace,
string name,
ISyntaxNodeProvider<EnumDeclarationSyntax> syntaxNodeProvider,
IUsingDirectives usingDirectives,
string location)
string location,
AEnumDeclarationLoader loader)
: base(nameSpace, name, syntaxNodeProvider, usingDirectives, location, true)
{
this.loader = loader;
}

/// <inheritdoc/>
protected override void LoadImpl(IDeclarationResolver resolver)
{
// Nothing to load...
this.loader.Load(this, resolver);
}

/// <inheritdoc/>
public IDeclarationUse<SyntaxNode>? UnderlyingType { get; internal set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ----------------------------------------------------------------------
// <copyright file="AEnumDeclarationLoader.cs" company="Xavier Solau">
// Copyright © 2021 Xavier Solau.
// Licensed under the MIT license.
// See LICENSE file in the project root for full license information.
// </copyright>
// ----------------------------------------------------------------------

using SoloX.GeneratorTools.Core.CSharp.Model.Resolver;

namespace SoloX.GeneratorTools.Core.CSharp.Model.Impl.Loader
{
/// <summary>
/// Enum Declaration Loader.
/// </summary>
public abstract class AEnumDeclarationLoader
{
/// <summary>
/// Load the given declaration.
/// </summary>
/// <param name="declaration">The generic declaration to load.</param>
/// <param name="resolver">The declaration resolver.</param>
internal abstract void Load(EnumDeclaration declaration, IDeclarationResolver resolver);
}
}
Loading
Loading