Skip to content

Commit

Permalink
Mono.CSharp uses the MSFT Reflection.Emit namespace to write its asse…
Browse files Browse the repository at this point in the history
…mblies, whereas the compiler in the Mono distro uses the IKVM reimplementations. There is a difference in behaviour in that the module MVId read from the Builder into the .mdb file is not the one written to the assembly in the Reflection.Emit case, leading to a symbol read failure due to mismatched GUID values.

Fix by updating the GUID in the .mdb from the .exe we generated, so we can have a sort-of Mono test in the CI build
  • Loading branch information
SteveGilham committed Dec 12, 2017
1 parent 9905a91 commit b7a8127
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Build/build.fsx
Expand Up @@ -264,6 +264,13 @@ Target "BuildMonoSamples" (fun _ ->
info.WorkingDirectory <- "."
info.Arguments <- (@"-debug -out:./_Mono/Sample1/Sample1.exe .\Sample1\Program.cs")) (TimeSpan.FromMinutes 5.0)
if result <> 0 then failwith "Mono compilation failed"

// Fix up symbol file to have the MVId emitted by the System.Reflection.Emit code
let assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom (FullName "./_Mono/Sample1/Sample1.exe")
let mvid = assembly.ManifestModule.ModuleVersionId.ToByteArray();
let symbols = System.IO.File.ReadAllBytes("./_Mono/Sample1/Sample1.exe.mdb")
mvid|> Array.iteri (fun i x -> symbols.[i+16] <- x)
System.IO.File.WriteAllBytes("./_Mono/Sample1/Sample1.exe.mdb", symbols)
)

let SimpleInstrumentingRun (samplePath:string) (binaryPath:string) (reportSigil:string) =
Expand Down
3 changes: 1 addition & 2 deletions MCS/MCS.fsproj
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -56,7 +55,7 @@
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="..\_Generated\AssemblyVersion.fs">
Expand Down

0 comments on commit b7a8127

Please sign in to comment.