Skip to content

Commit

Permalink
Do not overwrite metadataGenerationOptions
Browse files Browse the repository at this point in the history
Plus test coverage.

Fixes the issue reported in dotnet#7995.
  • Loading branch information
MichalStrehovsky committed Mar 23, 2020
1 parent f83e42d commit c2aeda6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ILCompiler/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private int Run(string[] args)
? new FrameworkStringResourceBlockingPolicy()
: (ManifestResourceBlockingPolicy)new NoManifestResourceBlockingPolicy();

metadataGenerationOptions = UsageBasedMetadataGenerationOptions.AnonymousTypeHeuristic;
metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.AnonymousTypeHeuristic;
if (_completeTypesMetadata)
metadataGenerationOptions |= UsageBasedMetadataGenerationOptions.CompleteTypesOnly;
if (_scanReflection)
Expand Down
9 changes: 9 additions & 0 deletions tests/src/Simple/PInvoke/PInvoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,12 @@ public class NonBlittableClass
public int f3;
}

[StructLayout(LayoutKind.Sequential)]
public class ClassForTestingFlowAnalysis
{
public int Field;
}

private static void TestStruct()
{
Console.WriteLine("Testing Structs");
Expand Down Expand Up @@ -983,6 +989,9 @@ private static void TestMarshalStructAPIs()
{
Marshal.FreeHGlobal(nbc_memory);
}

int cftf_size = Marshal.SizeOf(typeof(ClassForTestingFlowAnalysis));
ThrowIfNotEquals(4, cftf_size, "ClassForTestingFlowAnalysis marshalling Marshal API failed");
}
}

Expand Down

0 comments on commit c2aeda6

Please sign in to comment.