Skip to content

Commit

Permalink
publish HE
Browse files Browse the repository at this point in the history
  • Loading branch information
NMSAzulX committed Dec 3, 2024
1 parent 66a69a5 commit d21f943
Show file tree
Hide file tree
Showing 59 changed files with 358 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/NMS_TEMPLATE/codecov.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ${{nms.codecov}}

- name: 📶 Push to Codecov
if: ${{ needs.prepare.outputs.hasCoverageKey == 'true' }}
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v5.0.7
with:
token: ${{ secrets.COVERAGE_KEY }}
directory: ./coverage/
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,44 @@ jobs:
- name: 📶 Push to Nuget
if: ${{ needs.prepare_check.outputs.hasNugetKey == 'true' }}
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate

release:

runs-on: ubuntu-latest
needs: prepare_check
env:
RELEASE_VERSION: ${{needs.prepare_check.outputs.releaseVersion}}
PACK_STRING: ${{needs.prepare_check.outputs.releasePackString}}

steps:
- uses: actions/checkout@v4
- name: 🎉 Release
run: |
RELEASE_ID=$(gh api graphql -H "X-Github-Next-Global-ID: 1" -f query='
query{
repository(owner:"${{github.repository_owner}}",name:"${{github.event.repository.name}}"){
release(tagName:"v${{env.RELEASE_VERSION}}"){
id
}
}
}' --jq '.data.repository.release.id')
RESULT=0
if [ "$RELEASE_ID" != "" ]; then
if [ "$RELEASE_ID" != "null" ]; then
RESULT=1
fi
fi
if [ $RESULT == 0 ]; then
echo "::debug::no release package"
echo "不存在 Id ,开始创建 Release v${{env.RELEASE_VERSION}} 包!"
gh release create v${{env.RELEASE_VERSION}} -F CHANGELOG.md
else
echo "::debug::exist release package"
echo "该 Release v${{env.RELEASE_VERSION}} 包已存在!"
gh release edit v${{env.RELEASE_VERSION}} --notes-file CHANGELOG.md
fi
7 changes: 7 additions & 0 deletions Natasha.sln
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleSample", "samples\HE
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Natasha.CSharp.HotExecutor.Wrapper", "src\Natasha.CSharp\Extension\HotExecutor\Natasha.CSharp.HotExecutor.Wrapper\Natasha.CSharp.HotExecutor.Wrapper.csproj", "{8B5F2626-8EB0-44FF-9F1F-A1EFBCF8E030}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebapiSample", "samples\HE\NET8.0\WebapiSample\WebapiSample.csproj", "{B966C024-BA6A-40AE-B753-454E479BA686}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -481,6 +483,10 @@ Global
{8B5F2626-8EB0-44FF-9F1F-A1EFBCF8E030}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B5F2626-8EB0-44FF-9F1F-A1EFBCF8E030}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B5F2626-8EB0-44FF-9F1F-A1EFBCF8E030}.Release|Any CPU.Build.0 = Release|Any CPU
{B966C024-BA6A-40AE-B753-454E479BA686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B966C024-BA6A-40AE-B753-454E479BA686}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B966C024-BA6A-40AE-B753-454E479BA686}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B966C024-BA6A-40AE-B753-454E479BA686}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -577,6 +583,7 @@ Global
{915508A8-D118-4B5D-A17C-761C7033D32D} = {9546332D-450A-44D1-BF9B-52F43A7F7DDC}
{580C1DBC-5EDB-4C77-A5B9-456E7800BC43} = {915508A8-D118-4B5D-A17C-761C7033D32D}
{8B5F2626-8EB0-44FF-9F1F-A1EFBCF8E030} = {7A3EC767-1531-4472-8896-60B3F649BF34}
{B966C024-BA6A-40AE-B753-454E479BA686} = {02F43E76-07E7-408C-B64C-2CFF5BBB3D0C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3004E730-B231-40FA-B75C-58D7DDE17679}
Expand Down
9 changes: 7 additions & 2 deletions samples/DebugSample/DebugSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<PackageReference Include="DotNetCore.Natasha.CSharp.Compiler" Version="9.0.0.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp.Compiler.Domain" Version="9.0.0.1" />
</ItemGroup>

<!--<ItemGroup>
<ProjectReference Include="..\..\src\Natasha.CSharp\Component\Core\Natasha.CSharp.Compiler.Domain\Natasha.CSharp.Compiler.Domain.csproj" />
<ProjectReference Include="..\..\src\Natasha.CSharp\Natasha.CSharp.Compiler\Natasha.CSharp.Compiler.csproj" />
</ItemGroup>
</ItemGroup>-->

</Project>
2 changes: 1 addition & 1 deletion samples/DebugSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void Main(string[] args)
builder.UseRandomLoadContext();
builder.UseSmartMode();
//builder.WithFileOutput();
builder.WithDebugCompile(debugger => debugger.ForCore());
builder.WithDebugCompile(debugger => debugger.ForAssembly());
//builder.WithDebugCompile(debugger=>debugger.ForStandard());
builder.Add(@"public static class A{
public static long Show(int i,short j,double z){ return (long)(i + j + z + 10); }
Expand Down
8 changes: 4 additions & 4 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

<When Condition="('$(IsHEProject)' == 'true')">

<ItemGroup>
<!--<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\Natasha.CSharp\Extension\HotExecutor\Natasha.CSharp.HotExecutor\Natasha.CSharp.HotExecutor.csproj" />
<ProjectReference Include="$(SolutionDir)src\Natasha.CSharp\Component\Core\Natasha.CSharp.Compiler.Domain\Natasha.CSharp.Compiler.Domain.csproj" />
<ProjectReference Include="$(SolutionDir)src\Natasha.CSharp\Extension\Natasha.CSharp.Extension.MethodCreator\Natasha.CSharp.Extension.MethodCreator.csproj" />
</ItemGroup>
</ItemGroup>-->

</When>
</Choose>
<Choose>
<When Condition="('$(IsHEProject)' == 'true') And ('$(IsHENETCore30)' != 'true')">
<ItemGroup>
<!--<ItemGroup>
<ProjectReference Include="$(SolutionDir)src\Natasha.CSharp\Extension\HotExecutor\Natasha.CSharp.HotExecutor.SG\Natasha.CSharp.HotExecutor.SG.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
</ItemGroup>-->
</When>
</Choose>
</Project>
2 changes: 1 addition & 1 deletion samples/ExtensionSample/Class7.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Natasha.CSharp.HotExecutor.Component;
using Natasha.CSharp.HotExecutor.Utils;
using Natasha.CSharp.Extension.HotExecutor;
using ExtensionSample;
namespace System
Expand Down
10 changes: 8 additions & 2 deletions samples/ExtensionSample/ExtensionSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<Compile Remove="InteroAttribute.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetCore.Natasha.CSharp.Extension.CompileDirector" Version="9.0.0.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp.Extension.MethodCreator" Version="9.0.0.1" />
<PackageReference Include="DotNetCore.Natasha.CSharp.HotExecutor.Wrapper" Version="9.0.0.4" />
</ItemGroup>

<!--<ItemGroup>
<PackageReference Include="DotNetCore.Natasha.CSharp.HotExecutor.Wrapper" Version="9.0.0.3" />
</ItemGroup>-->
Expand All @@ -30,10 +36,10 @@
<PackageReference Include="DotNetCore.Natasha.CSharp.HotExecutor.Wrapper" Version="8.9.0" />
</ItemGroup>-->

<ItemGroup>
<!--<ItemGroup>
<ProjectReference Include="..\..\src\Natasha.CSharp\Component\Core\Natasha.CSharp.Compiler.Domain\Natasha.CSharp.Compiler.Domain.csproj" />
<ProjectReference Include="..\..\src\Natasha.CSharp\Extension\HotExecutor\Natasha.CSharp.HotExecutor.SG\Natasha.CSharp.HotExecutor.SG.csproj" />
<ProjectReference Include="..\..\src\Natasha.CSharp\Extension\HotExecutor\Natasha.CSharp.HotExecutor\Natasha.CSharp.HotExecutor.csproj" />
</ItemGroup>
</ItemGroup>-->

</Project>
27 changes: 20 additions & 7 deletions samples/ExtensionSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,20 @@ static void Main(string[] args)
}



//NatashaManagement
// .GetInitializer()
// .WithRefUsing()
// .WithRefReference()
// .WithMemoryUsing()
// .WithMemoryReference()
// .WithFileUsingCache()
// .WithExcludeReferences((asm, asmStr) => { return false; })
// .Preheating<NatashaDomainCreator>();

//var func = "return arg1 + arg2 + 0.1;"
// .WithMetadata<double>()
// .ToFunc<double, double, double>();
//Console.WriteLine(func(1, 2));
//Once
for (int i = 0; i < 5; i++)
{
Expand Down Expand Up @@ -116,14 +129,14 @@ public static void TestShow()
public static void Test()
{

//AssemblyCSharpBuilder assemblyCSharp = new();
//assemblyCSharp.ConfigLoadContext(ctx => ctx.AddReferenceAndUsingCode<object>());
//assemblyCSharp.Add("public class A{\r\npublic void Show(){\r\n}\r\n}");
//assemblyCSharp.LogCompilationEvent += (log) => { Console.WriteLine(log.ToString()); };
//assemblyCSharp.GetAssembly();
AssemblyCSharpBuilder assemblyCSharp = new();
assemblyCSharp.ConfigLoadContext(ctx => ctx.AddReferenceAndUsingCode<object>());
assemblyCSharp.Add("public class A{public void Show(){}}");
assemblyCSharp.LogCompilationEvent += (log) => { Console.WriteLine(log.ToString()); };
assemblyCSharp.GetAssembly();
//ProxyMainArguments();
//ProxyMain(args);


// TestCollection();
//TestPage();
Expand Down
50 changes: 29 additions & 21 deletions samples/HE/NET6.0/WebapiSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Natasha.CSharp.HotExecutor.Component;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.Extensions.Hosting;
using System;
using System.Linq;

namespace Webapi2Sample
{
public class Program
{
public static void Main(string[] args)
{
NatashaManagement.RegistDomainCreator<NatashaDomainCreator>();


//NatashaManagement.RegistDomainCreator<NatashaDomainCreator>();

//HE:Async
var builder = WebApplication.CreateBuilder(args);
Expand All @@ -25,25 +27,26 @@ public static void Main(string[] args)

var app = builder.Build();

var modelMetadataProvider = app.Services.GetService<IModelMetadataProvider>();
var controllerActivatorProvider = app.Services.GetService<IControllerActivatorProvider>();
//var modelMetadataProvider = app.Services.GetService<IModelMetadataProvider>();
//var controllerActivatorProvider = app.Services.GetService<IControllerActivatorProvider>();

//HEProxy.SetPreHotExecut(() => {

HEProxy.SetPreHotExecut(() => {
// var action = HEDelegateHelper.GetDelegate(modelMetadataProvider.GetType(), "ClearCache", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
// action(modelMetadataProvider);

var action = HEDelegateHelper.GetDelegate(modelMetadataProvider.GetType(), "ClearCache", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
action(modelMetadataProvider);
// var action2 = HEDelegateHelper.GetDelegate(controllerActivatorProvider.GetType(), "ClearCache", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
// action2(modelMetadataProvider);

var action2 = HEDelegateHelper.GetDelegate(controllerActivatorProvider.GetType(), "ClearCache", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
action2(modelMetadataProvider);
//});

});

var action = "arg1.ClearCache();arg2.ClearCache();Debug.WriteLine(1111);"
.WithSlimMethodBuilder()
.WithMetadata(typeof(Debug))
.WithPrivateAccess(typeof(IModelMetadataProvider), typeof(IControllerActivatorProvider))
.ToAction<IModelMetadataProvider, IControllerActivatorProvider>()!;
action(modelMetadataProvider!, controllerActivatorProvider!);
//var action = "arg1.ClearCache();arg2.ClearCache();Debug.WriteLine(1111);"
// .WithSlimMethodBuilder()
// .WithMetadata(typeof(Debug))
// .WithPrivateAccess(typeof(IModelMetadataProvider), typeof(IControllerActivatorProvider))
// .ToAction<IModelMetadataProvider, IControllerActivatorProvider>()!;
//action(modelMetadataProvider!, controllerActivatorProvider!);
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
Expand All @@ -53,11 +56,14 @@ public static void Main(string[] args)
app.AsyncToHotExecutor();
app.UseAuthorization();


var summaries = new[]
{
"Freezing1", "Bracing1", "Chilly1", "Cool1", "Mild1", "Warm1", "Balmy1", "Hot1", "Sweltering1", "Scorching1"
"Freezing441", "Bracing"
};



app.MapGet("/weatherforecast", (HttpContext httpContext) =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
Expand Down Expand Up @@ -103,6 +109,8 @@ public static void Main(string[] args)
.WithName("GetWeatherForecast2");

app.Run();
//Once
//Console.ReadKey();
}
}
}
2 changes: 2 additions & 0 deletions samples/HE/NET6.0/WebapiSample/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System;

namespace Webapi2Sample
{
public class WeatherForecast
Expand Down
14 changes: 11 additions & 3 deletions samples/HE/NET6.0/WebapiSample/WebapiSample.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetCore.Natasha.CSharp.HotExecutor.Wrapper" Version="9.0.0.6" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="DotNetCore.Natasha.CSharp.HotExecutor" Version="9.0.0.5" />
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion samples/HE/NET6.0/WebapiWIthController/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using System.Runtime.CompilerServices;

namespace WebapiWIthController
{
public class Program
{
public static void Main(string[] args)
{

NatashaManagement.RegistDomainCreator<NatashaDomainCreator>();

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -28,7 +30,7 @@ public static void Main(string[] args)
Console.WriteLine(1111);"
.WithMetadata(typeof(Console))
.WithUsings("Microsoft.AspNetCore.Mvc.Controllers")
//.WithMetadata(typeof(IgnoresAccessChecksToAttribute))
.WithMetadata(typeof(IgnoresAccessChecksToAttribute))
.WithMetadata(typeof(IModelMetadataProvider))
.WithPrivateAccess(typeof(DefaultModelMetadataProvider))
.ToAction<WebApplication>()!;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;

namespace WebapiSample.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}
Loading

0 comments on commit d21f943

Please sign in to comment.