Skip to content

Commit

Permalink
fix #1 support .net framework
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Nov 17, 2019
1 parent 8eba51b commit 8a98033
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ExpressionDebugger.Console/ExpressionDebugger.Console.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions ExpressionDebugger/ExpressionCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.Loader;
using System.Text;

namespace ExpressionDebugger
Expand Down Expand Up @@ -78,8 +77,11 @@ from n in t.TypeNames
if (_options?.References != null)
references.UnionWith(_options.References);
references.Add(typeof(object).Assembly);

#if NETSTANDARD2_0
references.Add(Assembly.Load(new AssemblyName("System.Runtime")));
references.Add(Assembly.Load(new AssemblyName("System.Collections")));
#endif

var assemblyName = Path.GetRandomFileName();
var symbolsName = Path.ChangeExtension(assemblyName, "pdb");
Expand Down Expand Up @@ -127,7 +129,11 @@ from n in t.TypeNames
assemblyStream.Seek(0, SeekOrigin.Begin);
symbolsStream.Seek(0, SeekOrigin.Begin);

return AssemblyLoadContext.Default.LoadFromStream(assemblyStream, symbolsStream);
#if NETSTANDARD2_0
return System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromStream(assemblyStream, symbolsStream);
#else
return Assembly.Load(assemblyStream.ToArray(), symbolsStream.ToArray());
#endif
}
}

Expand Down
6 changes: 4 additions & 2 deletions ExpressionDebugger/ExpressionDebugger.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Authors>Chaowlert Chaisrichalermpol</Authors>
<Description>Step into debugging from linq expressions</Description>
Expand All @@ -12,14 +12,16 @@
<SignAssembly>True</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<AssemblyOriginatorKeyFile>ExpressionDebugger.snk</AssemblyOriginatorKeyFile>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<FileVersion>2.1.0</FileVersion>
<AssemblyVersion>2.1.0</AssemblyVersion>
<PackageLicenseUrl>https://github.com/chaowlert/ExpressionDebugger/blob/master/LICENSE</PackageLicenseUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.8.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

Expand Down

0 comments on commit 8a98033

Please sign in to comment.