Skip to content

Commit

Permalink
Repro code for strange TypeLoadException
Browse files Browse the repository at this point in the history
  • Loading branch information
masonwheeler committed Jan 3, 2022
1 parent b0b8162 commit 92cfdc5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
8 changes: 1 addition & 7 deletions src/Boo.Core.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Boo.Lang.Parser.Tests.Core"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{3FD31683-A5EF-45B5-BD74-CEDFCF9A9EEA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lokad.ILPack", "..\..\ILPack\src\Lokad.ILPack.csproj", "{CFB4AE33-F886-4DD9-8855-F2B1AD6C5966}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Booc.Core", "booc\Booc.Core.csproj", "{2AAAA5D1-9D3C-414D-BAC7-7DC6FAFB790F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testcase", "Testcase\Testcase.csproj", "{C96E8F50-859F-4964-B7DD-727D052D8802}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Testcase\Test.csproj", "{C96E8F50-859F-4964-B7DD-727D052D8802}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -53,10 +51,6 @@ Global
{939974F4-9F00-4833-B897-962D2C28865F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{939974F4-9F00-4833-B897-962D2C28865F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{939974F4-9F00-4833-B897-962D2C28865F}.Release|Any CPU.Build.0 = Release|Any CPU
{CFB4AE33-F886-4DD9-8855-F2B1AD6C5966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFB4AE33-F886-4DD9-8855-F2B1AD6C5966}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFB4AE33-F886-4DD9-8855-F2B1AD6C5966}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFB4AE33-F886-4DD9-8855-F2B1AD6C5966}.Release|Any CPU.Build.0 = Release|Any CPU
{2AAAA5D1-9D3C-414D-BAC7-7DC6FAFB790F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AAAA5D1-9D3C-414D-BAC7-7DC6FAFB790F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AAAA5D1-9D3C-414D-BAC7-7DC6FAFB790F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
2 changes: 0 additions & 2 deletions src/Boo.Lang.Compiler/Boo.Lang.Compiler Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Lokad.ILPack" Version="0.1.7" />
<PackageReference Include="System.Security.Permissions" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\ILPack\src\Lokad.ILPack.csproj" />
<ProjectReference Include="..\Boo.Lang\Boo.Lang Core.csproj" />
</ItemGroup>

Expand Down
2 changes: 0 additions & 2 deletions src/Boo.Lang.Compiler/Steps/Ecma335/TypeSystemBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ public TypeSystemBridge(MetadataBuilder builder, TypeSystemServices tss, Func<IT
ValueTypeEntity = tss.ValueTypeType;
ObjectTypeEntity = tss.ObjectType;

/*
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
var runtimeName = loadedAssemblies.Single(a => a.GetName().Name == "System.Runtime").GetName();
var privateAsm = loadedAssemblies.Single(a => a.GetName().Name == "System.Private.CoreLib");
var handle = HandleForAssemblyName(runtimeName);
_assemblyLookup[privateAsm] = handle;
*/

ObjectType = (TypeReferenceHandle)LookupType(tss.ObjectType);
_getValue = getValue;
Expand Down
36 changes: 15 additions & 21 deletions src/Testcase/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using System;
using System.Linq;

namespace Testcase
class Program
{
public class Foo { }

public class Bar : Foo
{
virtual public void Run()
{
Console.WriteLine("Bar.Run");
}
}

internal class Program
static void Main()
{
static void Main(string[] args)
{
var foos = new Foo[] { new Bar(), new Bar() };
foreach (Bar foo in foos)
foo.Run();
}
}
}
var asm = typeof(C0).Assembly;
foreach (var type in asm.GetTypes())
{
Console.WriteLine(type.Name);
foreach (var arg in (Attribute.GetCustomAttribute(asm.GetType(type.Name), typeof(VarArgsAttribute)) as VarArgsAttribute).Args)
Console.WriteLine($"\t{arg}");
}
}
}
21 changes: 21 additions & 0 deletions src/Testcase/Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Boo.Lang\Boo.Lang Core.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="testcase">
<HintPath>C:\Users\mason\AppData\Local\Temp\testcase.dll</HintPath>
</Reference>
<Reference Include="varargs-attribute-external%2417">
<HintPath>C:\Users\mason\AppData\Local\Temp\varargs-attribute-external$17.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
8 changes: 0 additions & 8 deletions src/Testcase/Testcase.csproj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ code = [|
import System

[VarArgs]
class C0:
public class C0:
pass

[VarArgs("foo")]
Expand Down

0 comments on commit 92cfdc5

Please sign in to comment.