Skip to content

Commit

Permalink
Merge pull request #226 from dotnetcore/any
Browse files Browse the repository at this point in the history
更新 .NET8 版本并修复 UT 测试
  • Loading branch information
NMSAzulX authored Nov 15, 2023
2 parents 44ca43e + f0dacc1 commit 9bc2ba1
Show file tree
Hide file tree
Showing 55 changed files with 133 additions and 84 deletions.
3 changes: 1 addition & 2 deletions .github/NMS_TEMPLATE/test.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ jobs:
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x

${{nms.tests}}

Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ jobs:
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: 🚦 NatashaFunctionUT UT Test
run: dotnet test './test/ut/NatashaFunctionUT' --nologo -c Release -l "trx;LogFileName=NatashaFunctionUT.trx" --results-directory "TestResults"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Collections.Immutable;
using System.Diagnostics;

#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.IO;
using System.Reflection;
using Natasha.CSharp.Component.Domain;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Loader;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.IO;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.Text;
/// <summary>
/// 程序集编译构建器 - 语法树相关
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Compiler.SemanticAnalaysis;
using System;
using System.Runtime.CompilerServices;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;
using System.Collections.Concurrent;
using static System.Runtime.Loader.AssemblyLoadContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Natasha.CSharp.Component.Domain;
using Natasha.Domain.Extension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Natasha.CSharp.Component;
using Natasha.CSharp.Component.Domain;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.Reflection;
using System.Runtime.Loader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;
public static class NatashaTypeDomainExtension
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyModel;
using System;
Expand All @@ -25,7 +25,6 @@ public static void Preheating(Func<AssemblyName, string?, bool>? excludeReferenc
, bool useRuntimeReference = false
)
{

if (!_isCompleted)
{
lock (_lock)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;
using System.Threading.Tasks;

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

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;</TargetFrameworks>
<Description>Natasha 的 C# 版编译器</Description>
<PackageId>DotNetCore.Natasha.CSharp.Compiler</PackageId>
<PackageReleaseNotes>升级到最新版.</PackageReleaseNotes>
Expand All @@ -12,17 +12,15 @@
<AssemblyVersion>5.2.2.1</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' OR '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net5.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<DefineConstants>MULTI;</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageReference Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' OR '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net5.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<!--<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' OR '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net5.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net8.0'">
<ProjectReference Include="..\..\Natasha.Domain\Natasha.Domain.csproj" />
</ItemGroup>-->
<ItemGroup Condition="('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '3.0')))">
<ProjectReference Include="..\..\Natasha.Domain\Natasha.Domain.csproj" />
</ItemGroup>

Expand All @@ -42,5 +40,8 @@
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net7.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net7.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net7.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net8.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net8.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net8.0\DotNetCore.Natasha.CSharp.Compiler.targets" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

public static string ToReadonlyScript(this string field)
{

#if NET8_0_OR_GREATER
return $"Unsafe.AsRef(ref {field})";
#else
return $"Unsafe.AsRef({field})";

#endif
}

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

public static partial class NatashaManagement
{
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
/// <summary>
/// 和 NatashaInitializer.Preheating(); 一样
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Emit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using System;
using System.IO;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
/// <summary>
/// 程序集编译构建器 - 语法树相关
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Compiler.SemanticAnalaysis;
using System;
using System.Runtime.CompilerServices;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using System.Collections.Generic;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyModel;
using Natasha.CSharp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Component;
using System;
using System.Reflection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Template;

namespace Natasha.CSharp.Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Builder;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;

namespace Natasha.CSharp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
namespace Natasha.CSharp.Template
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System;

namespace Natasha.CSharp.Template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if MULTI
#if NETCOREAPP3_0_OR_GREATER
using System.Diagnostics;
using System.Text;

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

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;</TargetFrameworks>
<Description>Natasha 的编译模板</Description>
<PackageId>DotNetCore.Natasha.CSharp.Template</PackageId>
<PackageReleaseNotes>升级到最新版.</PackageReleaseNotes>
Expand All @@ -12,10 +12,6 @@
<AssemblyVersion>5.2.2.1</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' OR '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net5.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<DefineConstants>MULTI;</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Natasha.CSharp.Compiler\Natasha.CSharp.Compiler.csproj" />
</ItemGroup>
Expand All @@ -37,5 +33,8 @@
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net7.0\DotNetCore.Natasha.CSharp.Template.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net7.0\DotNetCore.Natasha.CSharp.Template.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net7.0\DotNetCore.Natasha.CSharp.Template.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net8.0\DotNetCore.Natasha.CSharp.Template.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net8.0\DotNetCore.Natasha.CSharp.Template.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net8.0\DotNetCore.Natasha.CSharp.Template.targets" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ public T Param<S>(string paramName, string keywords = "")
/// <returns></returns>
public virtual T Param(string type, string paramName, string keywords = "")
{


return Param($"{keywords}{type} {paramName}");

}
/// <summary>
/// 添加参数
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Template;

namespace Natasha.CSharp.Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using Natasha.CSharp.Builder;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using System;

namespace Natasha.CSharp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using System;

namespace Natasha.CSharp.Template
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !MULTI
#if !NETCOREAPP3_0_OR_GREATER
using System.Diagnostics;
using System.Text;

Expand Down
3 changes: 0 additions & 3 deletions src/Natasha.Domain/Core/NatashaDomain.Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Loader;
using System.Text;
using System.Threading;
using System.Xml.Linq;


public partial class NatashaDomain : AssemblyLoadContext
Expand Down
2 changes: 1 addition & 1 deletion src/Natasha.Domain/Core/NatashaDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected NatashaDomain() : base("Default")
_assemblyLoadBehavior = PluginLoadBehavior.None;
_excludePluginReferencesFunc = item => false;
_dependencyResolver = new AssemblyDependencyResolver(AppDomain.CurrentDomain.BaseDirectory!);
Unsafe.AsRef(DefaultDomain) = this;
Unsafe.AsRef(in DefaultDomain) = this;

}
public NatashaDomain(string key) : base(key, true)
Expand Down
5 changes: 4 additions & 1 deletion src/Natasha.Domain/Natasha.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;</TargetFrameworks>
<Description>Natasha 编译域的实现</Description>
<PackageId>DotNetCore.Natasha.Domain</PackageId>
<PackageReleaseNotes>升级</PackageReleaseNotes>
Expand All @@ -25,6 +25,9 @@
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net7.0\DotNetCore.Natasha.Domain.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net7.0\DotNetCore.Natasha.Domain.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net7.0\DotNetCore.Natasha.Domain.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="build\net8.0\DotNetCore.Natasha.Domain.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildTransitive\net8.0\DotNetCore.Natasha.Domain.targets" />
<None Include="Targets\Project.Usings.targets" Pack="true" PackagePath="buildMultiTargeting\net8.0\DotNetCore.Natasha.Domain.targets" />
</ItemGroup>

</Project>
Expand Down
4 changes: 2 additions & 2 deletions test/benchmark/BenchmarkProject/BenchmarkProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
</ItemGroup>
</Project>
Loading

0 comments on commit 9bc2ba1

Please sign in to comment.