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 sdk/libs/workflows #87

Merged
merged 5 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
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ indent_size = 4
insert_final_newline = true
charset = utf-8-bom

# IDE0305: コレクションの初期化を簡略化します
dotnet_style_prefer_collection_expression = true:silent

[*.cs]
#Core editorconfig formatting - indentation

Expand Down Expand Up @@ -47,7 +50,7 @@ csharp_preserve_single_line_blocks = true
#Style - expression bodied member options

#prefer expression-bodied members for methods
csharp_style_expression_bodied_methods =when_on_single_line:suggestion
csharp_style_expression_bodied_methods =when_on_single_line:silent
#prefer expression-bodied members for properties
csharp_style_expression_bodied_properties = true:suggestion

Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/build-release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,30 @@ env:

jobs:
get-version:
uses: kzrnm/dotnet-actions/.github/workflows/get-version.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/get-version.yml@v2
with:
project-path: Directory.Build.props

format:
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v2
with:
target: SourceExpander.sln
dotnet-version: 6.0.x
dotnet-version: |
8.0.x
6.0.x

build:
runs-on: windows-latest
needs: [get-version]
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- uses: actions/cache@v3
dotnet-version: |
8.0.x
6.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props') }}
Expand All @@ -45,7 +49,7 @@ jobs:
run: dotnet build ${{ env.WORKFLOW_BUILD_SLN }} -c Release
- name: Test
run: dotnet test ${{ env.WORKFLOW_BUILD_SLN }} --no-build --logger GitHubActions -c Release
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ needs.get-version.outputs.is-new == 'true' }}
with:
name: dist
Expand All @@ -54,7 +58,7 @@ jobs:
publish:
needs: [get-version, build, format]
if: ${{ needs.get-version.outputs.is-new == 'true' }}
uses: kzrnm/dotnet-actions/.github/workflows/publish.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/publish.yml@v2
with:
artifact-name: dist
version: ${{ needs.get-version.outputs.version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
name: TOC Generator
runs-on: ubuntu-latest
steps:
- uses: technote-space/toc-generator@v3
- uses: technote-space/toc-generator@v4
12 changes: 8 additions & 4 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ env:

jobs:
format:
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/format.yml@v2
with:
target: SourceExpander.sln
dotnet-version: 6.0.x
dotnet-version: |
8.0.x
6.0.x
test:
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v1
uses: kzrnm/dotnet-actions/.github/workflows/unittest.yml@v2
with:
target: SourceExpander.sln
dotnet-version: 6.0.x
dotnet-version: |
8.0.x
6.0.x
test-logger: GitHubActions
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgBase32768)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
Expand Down
11 changes: 9 additions & 2 deletions Source/Sandbox/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
�ソ<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<SourceExpander_Generator_StaticEmbeddingText>// Static Generate &#x9; // Property</SourceExpander_Generator_StaticEmbeddingText>
<TargetFramework>net8.0</TargetFramework>
<SourceExpander_Generator_StaticEmbeddingText>// Static Generate // Property</SourceExpander_Generator_StaticEmbeddingText>
<SourceExpander_Generator_ExpandingPosition>AfterUsings</SourceExpander_Generator_ExpandingPosition>
<SourceExpander_Generator_ExpandingAll>false</SourceExpander_Generator_ExpandingAll>
</PropertyGroup>
Expand All @@ -25,4 +25,11 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
11 changes: 9 additions & 2 deletions Source/Sandbox/SampleLibrary/SampleLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@
</ItemGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<SourceExpander_Embedder_Enabled>True</SourceExpander_Embedder_Enabled>
<SourceExpander_Embedder_EmbeddingType>raw</SourceExpander_Embedder_EmbeddingType>
<SourceExpander_Embedder_ExpandingSymbol>DEBUG</SourceExpander_Embedder_ExpandingSymbol>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ac-library-csharp" Version="3.0.0" />
<PackageReference Include="ac-library-csharp" Version="3.9.0" />
<ProjectReference Include="..\..\SourceExpander.Embedder\SourceExpander.Embedder.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Analyzer</OutputItemType>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
13 changes: 10 additions & 3 deletions Source/SourceExpander.Console/SourceExpander.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

Expand Down Expand Up @@ -33,9 +33,16 @@
<ItemGroup>
<PackageReference Include="Base32768" Version="2.0.2" />
<PackageReference Include="ConsoleAppFramework" Version="4.2.4" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
<PackageReference Include="Microsoft.Build" Version="17.0.0" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.6.10" />
<PackageReference Include="Microsoft.Build" Version="17.8.3" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions Source/SourceExpander.Core/SourceExpander.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
<NoWarn>$(NoWarn);IDE0057</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

<ItemGroup>
<PackageReference Include="Base32768" Version="2.0.2" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.8" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 4 additions & 6 deletions Source/SourceExpander.Embedder/EmbeddingResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private struct EmbeddingAssemblyMetadata
public string[] EmbeddedNamespaces;
public (string Raw, string GZipBase32768) EmbeddedSourceCode;

public IEnumerable<(string Key, string Value)> EnumerateMetadatas()
public readonly IEnumerable<(string Key, string Value)> EnumerateMetadatas()
{
if (!IsEnabled) yield break;

Expand Down Expand Up @@ -278,9 +278,7 @@ private SourceFileInfoRaw ParseSource(SyntaxTree tree)
cancellationToken.ThrowIfCancellationRequested();
var semanticModel = compilation.GetSemanticModel(tree, true);
var typeFindAndUnusedUsingRemover = new TypeFindAndUnusedUsingRemover(semanticModel, compilation.GetTypeByMetadataName(SourceExpander_NotEmbeddingSourceAttributeName), cancellationToken);
var newRoot = typeFindAndUnusedUsingRemover.CompilationUnit;
if (newRoot is null)
throw new Exception($"Syntax tree of {tree.FilePath} is invalid");
var newRoot = typeFindAndUnusedUsingRemover.CompilationUnit ?? throw new Exception($"Syntax tree of {tree.FilePath} is invalid");

cancellationToken.ThrowIfCancellationRequested();
SyntaxNode minified = config.MinifyLevel switch
Expand Down Expand Up @@ -326,15 +324,15 @@ private SourceFileInfo[] ResolveRaw(ImmutableArray<SourceFileInfoRaw> infos, IEn
foreach (var type in info.DefinedTypeNames)
{
if (!dependencyInfo.TryGetValue(type, out var deps))
dependencyInfo[type] = deps = new();
dependencyInfo[type] = deps = [];
deps.Add(info.FileName);
}
cancellationToken.ThrowIfCancellationRequested();
foreach (var info in otherInfos)
foreach (var type in info.TypeNames)
{
if (!dependencyInfo.TryGetValue(type, out var deps))
dependencyInfo[type] = deps = new();
dependencyInfo[type] = deps = [];
deps.Add(info.FileName);
}
var result = new SourceFileInfo[infos.Length];
Expand Down
7 changes: 7 additions & 0 deletions Source/SourceExpander.Embedder/SourceExpander.Embedder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
</Compile>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
Expand Down
2 changes: 1 addition & 1 deletion Source/SourceExpander.Share/Core/EmbeddedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{
var errors = ImmutableArray.CreateBuilder<(string Key, string ErrorMessage)>();
LanguageVersion csharpVersion = LanguageVersion.CSharp1;
Version? version = new(1, 0, 0);
Version version = new(1, 0, 0);
bool allowUnsafe = false;
ImmutableArray<string> embeddedNamespaces = ImmutableArray<string>.Empty;

Expand Down Expand Up @@ -67,7 +67,7 @@
case ParseResult.Status.NotMatch:
break;
case ParseResult.Status.Success:
version = attrVersion;

Check warning on line 70 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Converting null literal or possible null value to non-nullable type.

Check warning on line 70 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Converting null literal or possible null value to non-nullable type.

Check warning on line 70 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Converting null literal or possible null value to non-nullable type.

Check warning on line 70 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Converting null literal or possible null value to non-nullable type.

Check warning on line 70 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Converting null literal or possible null value to non-nullable type.
continue;
case ParseResult.Status.Error:
errors.Add((key, r.Message));
Expand Down Expand Up @@ -107,7 +107,7 @@
continue;
}
}
return (new EmbeddedData(assemblyName, builder.ToImmutable(), version, csharpVersion, allowUnsafe, embeddedNamespaces), errors.ToImmutable());

Check warning on line 110 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Possible null reference argument for parameter 'embedderVersion' in 'EmbeddedData.EmbeddedData(string assemblyName, ImmutableArray<SourceFileInfo> sources, Version embedderVersion, LanguageVersion csharpVersion, bool allowUnsafe, ImmutableArray<string> embeddedNamespaces)'.

Check warning on line 110 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Possible null reference argument for parameter 'embedderVersion' in 'EmbeddedData.EmbeddedData(string assemblyName, ImmutableArray<SourceFileInfo> sources, Version embedderVersion, LanguageVersion csharpVersion, bool allowUnsafe, ImmutableArray<string> embeddedNamespaces)'.

Check warning on line 110 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Possible null reference argument for parameter 'embedderVersion' in 'EmbeddedData.EmbeddedData(string assemblyName, ImmutableArray<SourceFileInfo> sources, Version embedderVersion, LanguageVersion csharpVersion, bool allowUnsafe, ImmutableArray<string> embeddedNamespaces)'.

Check warning on line 110 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Possible null reference argument for parameter 'embedderVersion' in 'EmbeddedData.EmbeddedData(string assemblyName, ImmutableArray<SourceFileInfo> sources, Version embedderVersion, LanguageVersion csharpVersion, bool allowUnsafe, ImmutableArray<string> embeddedNamespaces)'.

Check warning on line 110 in Source/SourceExpander.Share/Core/EmbeddedData.cs

View workflow job for this annotation

GitHub Actions / test / unittest

Possible null reference argument for parameter 'embedderVersion' in 'EmbeddedData.EmbeddedData(string assemblyName, ImmutableArray<SourceFileInfo> sources, Version embedderVersion, LanguageVersion csharpVersion, bool allowUnsafe, ImmutableArray<string> embeddedNamespaces)'.
}
private struct ParseResult
{
Expand Down
7 changes: 7 additions & 0 deletions Source/SourceExpander/SourceExpander.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,11 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Loading
Loading