-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable array support for the COM variant wrapper classes when built-…
…in COM is disabled. (#55756) * Disable array support for the COM variant wrapper classes when built-in COM is disabled. Fixes #55600 * Fix config call. * Fix one more location of wrapper class usage. * Fix method name. * Add trimming test. * Fix AV in IsArrayOfWrappers * Fix trimming test * Apply suggestions from code review Co-authored-by: Eric Erhardt <[email protected]> * Set Trim=true Co-authored-by: Elinor Fung <[email protected]> Co-authored-by: Eric Erhardt <[email protected]>
- Loading branch information
1 parent
f2a55e2
commit 62fad9d
Showing
6 changed files
with
86 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/libraries/System.Runtime/tests/TrimmingTests/TypeBuilderComDisabled.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("GeneratedAssembly"), AssemblyBuilderAccess.Run); | ||
ModuleBuilder module = assembly.DefineDynamicModule("GeneratedModule"); | ||
|
||
string typeName = "GeneratedType"; | ||
TypeBuilder genericType = module.DefineType(typeName); | ||
genericType.DefineField("_int", typeof(int), FieldAttributes.Private); | ||
genericType.DefineProperty("Prop", PropertyAttributes.None, typeof(string), null); | ||
|
||
Type generatedType = genericType.CreateType(); | ||
if (generatedType.Name != typeName) | ||
{ | ||
Console.WriteLine($"Unexpected name for generated type. Expected: {typeName}, Actual: {generatedType.Name}"); | ||
return -1; | ||
} | ||
|
||
object obj = Activator.CreateInstance(generatedType); | ||
string objAsString = obj.ToString(); | ||
if (objAsString != typeName) | ||
{ | ||
Console.WriteLine($"Unexpected result of ToString() for instance of generated type. Expected: {typeName}, Actual: {objAsString}"); | ||
return -2; | ||
} | ||
|
||
return 100; |