Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b0004fb

Browse files
committed
Address build feedback
1 parent 74018ff commit b0004fb

File tree

7 files changed

+85
-73
lines changed

7 files changed

+85
-73
lines changed

pkg/Microsoft.Private.PackageBaseline/packageIndex.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,10 +3466,9 @@
34663466
}
34673467
},
34683468
"System.Reflection.MetadataLoadContext": {
3469-
"BaselineVersion": "4.0.0",
34703469
"InboxOn": {},
34713470
"AssemblyVersionInPackageVersion": {
3472-
"4.0.0.0": "4.0.0"
3471+
"4.0.0.0": "4.6.0"
34733472
}
34743473
},
34753474
"System.Reflection.Primitives": {

pkg/descriptions.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,15 @@
13891389
"System.Reflection.PortableExecutable.ManagedPEBuilder"
13901390
]
13911391
},
1392+
{
1393+
"Name": "System.Reflection.MetataLoadContext",
1394+
"Description": "Provides read-only reflection on assemblies in an isolated context with support for assemblies that have different architectures and runtimes.",
1395+
"CommonTypes": [
1396+
"System.Reflection.MetadataLoadContext",
1397+
"System.Reflection.MetadataAssemblyResolver",
1398+
"System.Reflection.PathAssemblyResolver"
1399+
]
1400+
},
13921401
{
13931402
"Name": "System.Reflection.Primitives",
13941403
"Description": "Provides common enumerations for reflection-based libraries.",
@@ -2273,10 +2282,5 @@
22732282
"Name": "Microsoft.IO.Redist",
22742283
"Description": "Downlevel support package for System.IO classes.",
22752284
"CommonTypes": []
2276-
},
2277-
{
2278-
"Name": "System.Reflection.MetataLoadContext",
2279-
"Description": "Provides read-only reflection on assemblies in an isolated context with support for assemblies that have different architectures and runtimes.",
2280-
"CommonTypes": []
22812285
}
22822286
]

src/System.Reflection.MetadataLoadContext/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
<PropertyGroup>
55
<AssemblyVersion>4.0.0.0</AssemblyVersion>
66
<AssemblyKey>OPEN</AssemblyKey>
7-
<IsNETCoreApp>false</IsNETCoreApp>
87
</PropertyGroup>
98
</Project>

src/System.Reflection.MetadataLoadContext/src/Configurations.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<PackageConfigurations>
5-
netstandard;
6-
netcoreapp
7-
</PackageConfigurations>
84
<BuildConfigurations>
95
netstandard;
106
netcoreapp

src/System.Reflection.MetadataLoadContext/src/System.Reflection.MetadataLoadContext.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@
7979
<Compile Include="System\Reflection\TypeLoading\General\Ecma\MetadataTable.cs" />
8080
<Compile Include="System\Reflection\TypeLoading\General\HashHelpers.cs" />
8181
<Compile Include="System\Reflection\TypeLoading\General\Helpers.cs" />
82+
<Compile Include="System\Reflection\TypeLoading\General\Interop.netcoreapp.cs" Condition="'$(TargetGroup)' == 'netcoreapp'" />
83+
<Compile Include="System\Reflection\TypeLoading\General\Interop.netstandard.cs" Condition="'$(TargetGroup)' == 'netstandard'" />
8284
<Compile Include="System\Reflection\TypeLoading\General\MethodSig.cs" />
83-
<Compile Include="System\Reflection\TypeLoading\General\NetStandardBridge.cs" />
8485
<Compile Include="System\Reflection\TypeLoading\General\RoAssemblyName.cs" />
8586
<Compile Include="System\Reflection\TypeLoading\General\Sentinels.cs" />
8687
<Compile Include="System\Reflection\TypeLoading\General\TypeContext.cs" />
@@ -142,7 +143,7 @@
142143
<Compile Include="System\Reflection\TypeLoading\Types\RoType.TypeClassification.cs" />
143144
<Compile Include="System\Reflection\TypeLoading\Types\RoWrappedType.cs" />
144145
</ItemGroup>
145-
<ItemGroup>
146+
<ItemGroup Condition="'$(TargetsNetCoreApp)' == 'true'">
146147
<Reference Include="System.Runtime" />
147148
<Reference Include="System.Runtime.CompilerServices.Unsafe" />
148149
<Reference Include="System.Runtime.Extensions" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
// This file makes NetStandard Reflection's "subclassing" surface area look as much like NetCore as possible so the rest of the code can be written without #if's.
6+
7+
namespace System.Reflection.TypeLoading
8+
{
9+
internal static class NetCoreApiEmulators
10+
{
11+
// On NetCore, call the real thing.
12+
13+
public static bool IsSignatureType(this Type type) => type.IsSignatureType;
14+
public static bool IsSZArray(this Type type) => type.IsSZArray;
15+
public static bool IsVariableBoundArray(this Type type) => type.IsVariableBoundArray;
16+
public static bool IsGenericMethodParameter(this Type type) => type.IsGenericMethodParameter;
17+
public static Type MakeSignatureGenericType(this Type genericTypeDefinition, Type[] typeArguments) => Type.MakeGenericSignatureType(genericTypeDefinition, typeArguments);
18+
}
19+
20+
/// <summary>
21+
/// Another layer of base types. For NetCore, these base types are empty. For NetStandard, these base types add the NetCore apis to NetStandard
22+
/// so code interacting with "RoTypes" and friends can happily code to the full NetCore surface area.
23+
/// </summary>
24+
internal abstract class LeveledTypeInfo : TypeInfo
25+
{
26+
protected LeveledTypeInfo() : base() { }
27+
}
28+
29+
internal abstract class LeveledAssembly : Assembly
30+
{
31+
}
32+
33+
internal abstract class LeveledConstructorInfo : ConstructorInfo
34+
{
35+
}
36+
37+
internal abstract class LeveledMethodInfo : MethodInfo
38+
{
39+
}
40+
41+
internal abstract class LeveledEventInfo : EventInfo
42+
{
43+
}
44+
45+
internal abstract class LeveledFieldInfo : FieldInfo
46+
{
47+
}
48+
49+
internal abstract class LeveledPropertyInfo : PropertyInfo
50+
{
51+
}
52+
53+
internal abstract class LeveledCustomAttributeData : CustomAttributeData
54+
{
55+
}
56+
}
Lines changed: 16 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,41 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
//
65
// This file makes NetStandard Reflection's "subclassing" surface area look as much like NetCore as possible so the rest of the code can be written without #if's.
7-
//
86

97
namespace System.Reflection.TypeLoading
108
{
11-
//
12-
// For code (usually shared with other repos) that have to interact with "Type" rather than "RoType", some handy extension methods that
13-
// "add" the NetCore reflection apis back to NetStandard.
14-
//
9+
// For code that have to interact with "Type" rather than "RoType", some handy extension methods that "add" the NetCore reflection apis to NetStandard.
1510
internal static class NetCoreApiEmulators
1611
{
17-
#if netstandard
1812
// On NetStandard, have to do with slower emulations.
1913

2014
public static bool IsSignatureType(this Type type) => false;
2115
public static bool IsSZArray(this Type type) => type.IsArray && type.GetArrayRank() == 1 && type.Name.EndsWith("[]");
2216
public static bool IsVariableBoundArray(this Type type) => type.IsArray && !type.IsSZArray();
2317
public static bool IsGenericMethodParameter(this Type type) => type.IsGenericParameter && type.DeclaringMethod != null;
2418

25-
// Signature Types do not exist on NetStandard 2.0 but it's possible we could reach this if a NetCore app uses the NetStandard build
26-
// of this library.
19+
// Signature Types do not exist on NetStandard 2.0 but it's possible we could reach this if a NetCore app uses the NetStandard build of this library.
2720
public static Type MakeSignatureGenericType(this Type genericTypeDefinition, Type[] typeArguments) => throw new NotSupportedException(SR.NotSupported_MakeGenericType_SignatureTypes);
28-
#else
29-
// On NetCore, call the real thing.
30-
31-
public static bool IsSignatureType(this Type type) => type.IsSignatureType;
32-
public static bool IsSZArray(this Type type) => type.IsSZArray;
33-
public static bool IsVariableBoundArray(this Type type) => type.IsVariableBoundArray;
34-
public static bool IsGenericMethodParameter(this Type type) => type.IsGenericMethodParameter;
35-
36-
// @TODO - https://github.com/dotnet/corefxlab/issues/2443: This should be fixed assuming https://github.com/dotnet/corefx/issues/31798 gets approved.
37-
public static Type MakeSignatureGenericType(this Type genericTypeDefinition, Type[] typeArguments) => throw new NotSupportedException(SR.NotSupported_MakeGenericType_SignatureTypes);
38-
#endif
3921
}
4022

41-
//
42-
// Another layer of base types. For NetCore, these base types are all but empty. For NetStandard, these base types add the NetCore apis to NetStandard
43-
// so code interacting with "RoTypes" and friends can happily code to the full NetCore surface area.
44-
//
45-
// On NetStandard and pre-2.2 NetCore, the TypeInfo constructor is not exposed so we cannot derive directly from TypeInfo.
46-
// But we *can* derive from TypeDelegator which derives from TypeInfo. Since we're overriding (almost) every method,
47-
// none of TypeDelegator's own methods get called (and the instance field it has for holding the "underlying Type" goes
48-
// to waste.)
49-
//
50-
// For future platforms, RoTypeBase's base type should be changed back to TypeInfo. Deriving from TypeDelegator is a hack and
51-
// causes us to waste an extra pointer-sized field per Type instance. It is also fragile as TypeDelegator could break us in the future
52-
// by overriding more methods.
53-
//
54-
internal abstract class LeveledTypeInfo :
55-
#if netstandard
56-
TypeDelegator
57-
#else
58-
TypeInfo
59-
#endif
23+
/// <summary>
24+
/// Another layer of base types. For NetCore, these base types are all but empty. For NetStandard, these base types add the NetCore apis to NetStandard
25+
/// so code interacting with "RoTypes" and friends can happily code to the full NetCore surface area.
26+
///
27+
/// On NetStandard (and pre-2.2 NetCore), the TypeInfo constructor is not exposed so we cannot derive directly from TypeInfo.
28+
/// But we *can* derive from TypeDelegator which derives from TypeInfo. Since we're overriding (almost) every method,
29+
/// none of TypeDelegator's own methods get called (and the instance field it has for holding the "underlying Type" goes
30+
/// to waste.)
31+
///
32+
/// For future platforms, RoTypeBase's base type should be changed back to TypeInfo. Deriving from TypeDelegator is a hack and
33+
/// causes us to waste an extra pointer-sized field per Type instance. It is also fragile as TypeDelegator could break us in the future
34+
/// by overriding more methods.
35+
/// </summary>
36+
internal abstract class LeveledTypeInfo : TypeDelegator
6037
{
6138
protected LeveledTypeInfo() : base() { }
6239

63-
#if netstandard
6440
// This is an api that TypeDelegator overrides that it needn't have. Since RoType expects to fall through to System.Type's method, we have to reimplement
6541
// System.Type's behavior here to avoid getting TypeDelegator's method.
6642
//
@@ -77,62 +53,43 @@ protected LeveledTypeInfo() : base() { }
7753
public virtual bool IsSignatureType => false;
7854
protected abstract MethodInfo GetMethodImpl(string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers);
7955
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
80-
#endif // netstandard
8156
}
8257

8358
internal abstract class LeveledAssembly : Assembly
8459
{
85-
#if netstandard
8660
public abstract Type[] GetForwardedTypes();
87-
#endif // netstandard
8861
}
8962

9063
internal abstract class LeveledConstructorInfo : ConstructorInfo
9164
{
92-
#if netstandard
9365
public abstract bool IsConstructedGenericMethod { get; }
9466
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
95-
#endif // netstandard
9667
}
9768

9869
internal abstract class LeveledMethodInfo : MethodInfo
9970
{
100-
#if netstandard
10171
public abstract bool IsConstructedGenericMethod { get; }
10272
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
103-
#endif // netstandard
10473
}
10574

10675
internal abstract class LeveledEventInfo : EventInfo
10776
{
108-
#if netstandard
10977
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
110-
#endif // netstandard
11178
}
11279

11380
internal abstract class LeveledFieldInfo : FieldInfo
11481
{
115-
#if netstandard
11682
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
117-
#endif // netstandard
11883
}
11984

12085
internal abstract class LeveledPropertyInfo : PropertyInfo
12186
{
122-
#if netstandard
12387
public abstract bool HasSameMetadataDefinitionAs(MemberInfo other);
124-
#endif // netstandard
12588
}
12689

12790
internal abstract class LeveledCustomAttributeData : CustomAttributeData
12891
{
129-
#if netstandard
13092
// On NetStandard, AttributeType is declared non-virtually so apps are stuck calling the slow version that builds a constructor.
13193
public new abstract Type AttributeType { get; }
132-
#else
133-
// @todo: https://github.com/dotnet/corefxlab/issues/2460 Once the netcore build is building against a contract that declares AttributeType virtually,
134-
// delete this line. We want RoCustomAttributeData to override the real AttributeType property.
135-
public new abstract Type AttributeType { get; }
136-
#endif // netstandard
13794
}
13895
}

0 commit comments

Comments
 (0)