Recovery CSScript.Core

This commit is contained in:
28810 2020-03-15 10:53:17 +08:00
parent 8ddf117fc7
commit 529be7d9d2
2 changed files with 29 additions and 5 deletions

View File

@ -22,9 +22,18 @@
<None Include="../../logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="CS-Script.Core" Version="1.2.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="CS-Script.Core" Version="1.3.1" />
</ItemGroup>
<!--
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="DotNetCore.Natasha" Version="2.12.0" />
</ItemGroup>
-->
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netstandard2.1'">
<DefineConstants>ns20;netstandard20</DefineConstants>

View File

@ -10,12 +10,27 @@ namespace FreeSql.Extensions.LazyLoading
{
#if ns20
//public static Assembly CompileCode(string cscode)
//{
// Natasha.AssemblyComplier complier = new Natasha.AssemblyComplier();
// //complier.Domain = DomainManagment.Random;
// complier.Add(cscode);
// return complier.GetAssembly();
//}
internal static Lazy<CSScriptLib.RoslynEvaluator> _compiler = new Lazy<CSScriptLib.RoslynEvaluator>(() =>
{
var compiler = new CSScriptLib.RoslynEvaluator();
compiler.DisableReferencingFromCode = false;
compiler
.ReferenceAssemblyOf<IFreeSql>()
.ReferenceDomainAssemblies();
return compiler;
});
public static Assembly CompileCode(string cscode)
{
Natasha.AssemblyComplier complier = new Natasha.AssemblyComplier();
//complier.Domain = DomainManagment.Random;
complier.Add(cscode);
return complier.GetAssembly();
return _compiler.Value.CompileCode(cscode);
}
#else