File tree Expand file tree Collapse file tree 7 files changed +70
-3
lines changed
TestNFClassLibrary/TestNFClassLibrary Expand file tree Collapse file tree 7 files changed +70
-3
lines changed Original file line number Diff line number Diff line change @@ -713,7 +713,16 @@ private HashSet<MetadataToken> BuildDependencyList(MetadataToken token)
713
713
{
714
714
if ( v . VariableType . DeclaringType != null )
715
715
{
716
- set . Add ( v . VariableType . DeclaringType . MetadataToken ) ;
716
+ var resolvedType = v . VariableType . Resolve ( ) ;
717
+
718
+ if ( resolvedType != null && resolvedType . IsEnum )
719
+ {
720
+ set . Add ( v . VariableType . MetadataToken ) ;
721
+ }
722
+ else
723
+ {
724
+ set . Add ( v . VariableType . DeclaringType . MetadataToken ) ;
725
+ }
717
726
}
718
727
else if ( v . VariableType . MetadataType == MetadataType . Class )
719
728
{
Original file line number Diff line number Diff line change @@ -41,9 +41,9 @@ public void DumpAssemblyTest()
41
41
Assert . IsTrue ( dumpFileContent . Contains ( "TypeRefProps [01000001]: Scope: 23000001 'System.Diagnostics.DebuggableAttribute'" ) ) ;
42
42
Assert . IsTrue ( dumpFileContent . Contains ( ": Scope: 23000002 'TestNFClassLibrary.ClassOnAnotherAssembly'" ) ) ;
43
43
44
- Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 00001001 Extends: 0100000d Enclosed: 02000000 'TestNFApp.DummyCustomAttribute1'" ) ) ;
44
+ Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 00001001 Extends: 0100000f Enclosed: 02000000 'TestNFApp.DummyCustomAttribute1'" ) ) ;
45
45
46
- Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 00001001 Extends: 0100000d Enclosed: 02000000 'TestNFApp.DummyCustomAttribute2'" ) ) ;
46
+ Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 00001001 Extends: 0100000f Enclosed: 02000000 'TestNFApp.DummyCustomAttribute2'" ) ) ;
47
47
48
48
Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 00001061 Extends: 01000000 Enclosed: 02000000 'TestNFApp.IOneClassOverAll'" ) ) ;
49
49
Assert . IsTrue ( dumpFileContent . Contains ( ": Flags: 000007c6 Impl: 00000000 RVA: 00000000 'get_DummyProperty' [I4( )]" ) ) ;
Original file line number Diff line number Diff line change 5
5
6
6
using System ;
7
7
using System . Diagnostics ;
8
+ using System . IO ;
8
9
using System . Reflection ;
9
10
using TestNFClassLibrary ;
10
11
@@ -36,6 +37,26 @@ public static void Main()
36
37
// Reflection Tests
37
38
ReflectionTests ( ) ;
38
39
40
+ ////////////////////////////////////////////////
41
+ // Test enum in another assembly, same namespace
42
+ var enumTest = new TestEnumInAnotherAssembly ( ) ;
43
+ enumTest . CallTestEnumInAnotherAssembly ( ) ;
44
+
45
+ /////////////////////////////////////
46
+ // reference enum in another assembly
47
+ var x = ( IAmAClassWithAnEnum . EnumA ) 1 ;
48
+
49
+ var messageType = ( IAmAClassWithAnEnum . EnumA ) 0 ;
50
+ switch ( messageType )
51
+ {
52
+ case IAmAClassWithAnEnum . EnumA . Test :
53
+ Console . WriteLine ( "all good" ) ;
54
+ break ;
55
+
56
+ default :
57
+ break ;
58
+ }
59
+
39
60
Debug . WriteLine ( "Exiting TestNFApp" ) ;
40
61
}
41
62
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) .NET Foundation and Contributors
3
+ // See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ namespace System . IO
7
+ {
8
+ public class TestEnumInAnotherAssembly
9
+ {
10
+ public void CallTestEnumInAnotherAssembly ( )
11
+ {
12
+ // This test checks if MDP can minimize the assembly using an enum that is defined in another assembly
13
+ // and the class calling it is in a different assembly BUT in the same namespace.
14
+ var ioException = new IOException (
15
+ string . Empty ,
16
+ ( int ) IOException . IOExceptionErrorCode . DirectoryNotFound ) ;
17
+ }
18
+ }
19
+
20
+ }
Original file line number Diff line number Diff line change 26
26
<Compile Include =" IOneClassOverAll.cs" />
27
27
<Compile Include =" ComplexAttribute.cs" />
28
28
<Compile Include =" MaxAttribute.cs" />
29
+ <Compile Include =" TestEnumInAnotherAssembly.cs" />
29
30
<Compile Include =" MyAttribute.cs" />
30
31
<Compile Include =" MyClass1.cs" />
31
32
<Compile Include =" OneClassOverAll.cs" />
Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) .NET Foundation and Contributors
3
+ // See LICENSE file in the project root for full license information.
4
+ //
5
+
6
+ namespace TestNFClassLibrary
7
+ {
8
+ public class IAmAClassWithAnEnum
9
+ {
10
+ public enum EnumA
11
+ {
12
+ Test = 1
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change 18
18
</PropertyGroup >
19
19
<Import Project =" $(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition =" Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
20
20
<ItemGroup >
21
+ <Compile Include =" IAmAClassWithAnEnum.cs" />
21
22
<Compile Include =" ClassOnAnotherAssembly.cs" />
22
23
<Compile Include =" Properties\AssemblyInfo.cs" />
23
24
</ItemGroup >
You can’t perform that action at this time.
0 commit comments