Skip to content

Commit 6002cc4

Browse files
jkotasRuihan-Yin
authored andcommitted
Change S.R.M.TypeName to be consumed from System.Reflection.Metadata package (dotnet#101666)
Contributes to dotnet#101541 Fixes dotnet#101628
1 parent 7a931b6 commit 6002cc4

File tree

14 files changed

+118
-143
lines changed

14 files changed

+118
-143
lines changed

eng/Version.Details.xml

+18-18
Original file line numberDiff line numberDiff line change
@@ -282,43 +282,43 @@
282282
<Uri>https://github.com/dotnet/llvm-project</Uri>
283283
<Sha>26f8c30340764cfa7fa9090dc01a36c222bf09c1</Sha>
284284
</Dependency>
285-
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="9.0.0-preview.4.24219.3">
285+
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="9.0.0-preview.4.24227.6">
286286
<Uri>https://github.com/dotnet/runtime</Uri>
287-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
287+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
288288
</Dependency>
289-
<Dependency Name="runtime.native.System.IO.Ports" Version="9.0.0-preview.4.24219.3">
289+
<Dependency Name="runtime.native.System.IO.Ports" Version="9.0.0-preview.4.24227.6">
290290
<Uri>https://github.com/dotnet/runtime</Uri>
291-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
291+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
292292
</Dependency>
293-
<Dependency Name="Microsoft.NETCore.ILAsm" Version="9.0.0-preview.4.24219.3">
293+
<Dependency Name="Microsoft.NETCore.ILAsm" Version="9.0.0-preview.4.24227.6">
294294
<Uri>https://github.com/dotnet/runtime</Uri>
295-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
295+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
296296
</Dependency>
297-
<Dependency Name="Microsoft.NET.Sdk.IL" Version="9.0.0-preview.4.24219.3">
297+
<Dependency Name="Microsoft.NET.Sdk.IL" Version="9.0.0-preview.4.24227.6">
298298
<Uri>https://github.com/dotnet/runtime</Uri>
299-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
299+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
300300
</Dependency>
301-
<Dependency Name="System.Text.Json" Version="9.0.0-preview.4.24219.3">
301+
<Dependency Name="System.Text.Json" Version="9.0.0-preview.4.24227.6">
302302
<Uri>https://github.com/dotnet/runtime</Uri>
303-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
303+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
304304
</Dependency>
305305
<!-- Intermediate is necessary for source build. -->
306-
<Dependency Name="Microsoft.SourceBuild.Intermediate.runtime.linux-x64" Version="9.0.0-preview.4.24219.3">
306+
<Dependency Name="Microsoft.SourceBuild.Intermediate.runtime.linux-x64" Version="9.0.0-preview.4.24227.6">
307307
<Uri>https://github.com/dotnet/runtime</Uri>
308-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
308+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
309309
<SourceBuild RepoName="runtime" ManagedOnly="false" />
310310
</Dependency>
311-
<Dependency Name="Microsoft.DotNet.ILCompiler" Version="9.0.0-preview.4.24219.3">
311+
<Dependency Name="Microsoft.DotNet.ILCompiler" Version="9.0.0-preview.4.24227.6">
312312
<Uri>https://github.com/dotnet/runtime</Uri>
313-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
313+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
314314
</Dependency>
315-
<Dependency Name="System.Reflection.Metadata" Version="9.0.0-preview.4.24219.3">
315+
<Dependency Name="System.Reflection.Metadata" Version="9.0.0-preview.4.24227.6">
316316
<Uri>https://github.com/dotnet/runtime</Uri>
317-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
317+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
318318
</Dependency>
319-
<Dependency Name="System.Reflection.MetadataLoadContext" Version="9.0.0-preview.4.24219.3">
319+
<Dependency Name="System.Reflection.MetadataLoadContext" Version="9.0.0-preview.4.24227.6">
320320
<Uri>https://github.com/dotnet/runtime</Uri>
321-
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
321+
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
322322
</Dependency>
323323
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24224.1">
324324
<Uri>https://github.com/dotnet/xharness</Uri>

eng/Versions.props

+7-7
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@
104104
<!-- NuGet dependencies -->
105105
<NuGetBuildTasksPackVersion>6.0.0-preview.1.102</NuGetBuildTasksPackVersion>
106106
<!-- Installer dependencies -->
107-
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.0-preview.4.24219.3</MicrosoftNETCoreAppRuntimewinx64Version>
107+
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.0-preview.4.24227.6</MicrosoftNETCoreAppRuntimewinx64Version>
108108
<MicrosoftExtensionsDependencyModelVersion>6.0.0</MicrosoftExtensionsDependencyModelVersion>
109109
<!-- ILAsm dependencies -->
110-
<MicrosoftNETCoreILAsmVersion>9.0.0-preview.4.24219.3</MicrosoftNETCoreILAsmVersion>
110+
<MicrosoftNETCoreILAsmVersion>9.0.0-preview.4.24227.6</MicrosoftNETCoreILAsmVersion>
111111
<!-- Libraries dependencies -->
112112
<MicrosoftBclAsyncInterfacesVersion>6.0.0</MicrosoftBclAsyncInterfacesVersion>
113113
<MicrosoftBclHashCodeVersion>1.1.1</MicrosoftBclHashCodeVersion>
@@ -119,19 +119,19 @@
119119
<SystemDrawingCommonVersion>8.0.0</SystemDrawingCommonVersion>
120120
<SystemIOFileSystemAccessControlVersion>5.0.0</SystemIOFileSystemAccessControlVersion>
121121
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
122-
<SystemReflectionMetadataVersion>9.0.0-preview.4.24219.3</SystemReflectionMetadataVersion>
123-
<SystemReflectionMetadataLoadContextVersion>9.0.0-preview.4.24219.3</SystemReflectionMetadataLoadContextVersion>
122+
<SystemReflectionMetadataVersion>9.0.0-preview.4.24227.6</SystemReflectionMetadataVersion>
123+
<SystemReflectionMetadataLoadContextVersion>9.0.0-preview.4.24227.6</SystemReflectionMetadataLoadContextVersion>
124124
<SystemSecurityAccessControlVersion>6.0.0</SystemSecurityAccessControlVersion>
125125
<SystemSecurityCryptographyCngVersion>5.0.0</SystemSecurityCryptographyCngVersion>
126126
<SystemSecurityCryptographyOpenSslVersion>5.0.0</SystemSecurityCryptographyOpenSslVersion>
127127
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
128128
<SystemSecurityPermissionsVersion>7.0.0</SystemSecurityPermissionsVersion>
129-
<SystemTextJsonVersion>9.0.0-preview.4.24219.3</SystemTextJsonVersion>
129+
<SystemTextJsonVersion>9.0.0-preview.4.24227.6</SystemTextJsonVersion>
130130
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
131131
<SystemThreadingAccessControlVersion>7.0.0</SystemThreadingAccessControlVersion>
132132
<SystemThreadingTasksExtensionsVersion>4.5.4</SystemThreadingTasksExtensionsVersion>
133133
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
134-
<runtimenativeSystemIOPortsVersion>9.0.0-preview.4.24219.3</runtimenativeSystemIOPortsVersion>
134+
<runtimenativeSystemIOPortsVersion>9.0.0-preview.4.24227.6</runtimenativeSystemIOPortsVersion>
135135
<!-- Keep toolset versions in sync with dotnet/msbuild and dotnet/sdk -->
136136
<SystemCollectionsImmutableToolsetVersion>8.0.0</SystemCollectionsImmutableToolsetVersion>
137137
<SystemTextJsonToolsetVersion>8.0.0</SystemTextJsonToolsetVersion>
@@ -210,7 +210,7 @@
210210
<!-- Mono Cecil -->
211211
<MicrosoftDotNetCecilVersion>0.11.4-alpha.24222.1</MicrosoftDotNetCecilVersion>
212212
<!-- ILCompiler -->
213-
<MicrosoftDotNetILCompilerVersion>9.0.0-preview.4.24219.3</MicrosoftDotNetILCompilerVersion>
213+
<MicrosoftDotNetILCompilerVersion>9.0.0-preview.4.24227.6</MicrosoftDotNetILCompilerVersion>
214214
<!-- ICU -->
215215
<MicrosoftNETCoreRuntimeICUTransportVersion>9.0.0-preview.5.24223.2</MicrosoftNETCoreRuntimeICUTransportVersion>
216216
<!-- MsQuic -->

src/coreclr/tools/Common/TypeSystem/Common/Utilities/CustomAttributeTypeNameParser.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ namespace System.Reflection
2929
{
3030
internal partial struct TypeNameParser
3131
{
32+
private static readonly TypeNameParseOptions s_typeNameParseOptions = new() { MaxNodes = int.MaxValue };
33+
3234
private ModuleDesc _module;
3335
private bool _throwIfNotFound;
3436
private Func<ModuleDesc, string, MetadataType> _canonResolver;
3537

3638
public static TypeDesc ResolveType(ModuleDesc module, string name, bool throwIfNotFound,
3739
Func<ModuleDesc, string, MetadataType> canonResolver)
3840
{
39-
if (!TypeName.TryParse(name.AsSpan(), out TypeName parsed))
41+
if (!TypeName.TryParse(name.AsSpan(), out TypeName parsed, s_typeNameParseOptions))
4042
{
4143
ThrowHelper.ThrowTypeLoadException(name, module);
4244
}

src/coreclr/tools/ILVerification/ILVerification.projitems

-24
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,6 @@
6666
<Compile Include="$(ToolsCommonPath)TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs">
6767
<Link>Utilities\CustomAttributeTypeNameParser.cs</Link>
6868
</Compile>
69-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\HexConverter.cs">
70-
<Link>Utilities\HexConverter.cs</Link>
71-
</Compile>
72-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameFormatter.cs">
73-
<Link>Utilities\AssemblyNameFormatter.cs</Link>
74-
</Compile>
75-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameParser.cs">
76-
<Link>Utilities\AssemblyNameParser.cs</Link>
77-
</Compile>
78-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\AssemblyNameInfo.cs">
79-
<Link>Utilities\Metadata\AssemblyNameInfo.cs</Link>
80-
</Compile>
81-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeName.cs">
82-
<Link>Utilities\TypeName.cs</Link>
83-
</Compile>
84-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserOptions.cs">
85-
<Link>Utilities\TypeNameParserOptions.cs</Link>
86-
</Compile>
87-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParser.cs">
88-
<Link>Utilities\TypeNameParser.cs</Link>
89-
</Compile>
90-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserHelpers.cs">
91-
<Link>Utilities\TypeNameParserHelpers.cs</Link>
92-
</Compile>
9369
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
9470
<Link>System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs</Link>
9571
</Compile>

src/coreclr/tools/ILVerify/ILVerify.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20+
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
2021
<PackageReference Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
2122
</ItemGroup>
2223
</Project>

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/TypeNameParser.Dataflow.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace System.Reflection
99
{
1010
internal partial struct TypeNameParser
1111
{
12+
private static readonly TypeNameParseOptions s_typeNameParseOptions = new() { MaxNodes = int.MaxValue };
13+
1214
private TypeSystemContext _context;
1315
private ModuleDesc _callingModule;
1416
private List<ModuleDesc> _referencedModules;
@@ -17,7 +19,7 @@ internal partial struct TypeNameParser
1719
public static TypeDesc ResolveType(string name, ModuleDesc callingModule,
1820
TypeSystemContext context, List<ModuleDesc> referencedModules, out bool typeWasNotFoundInAssemblyNorBaseLibrary)
1921
{
20-
if (!TypeName.TryParse(name, out TypeName parsed))
22+
if (!TypeName.TryParse(name, out TypeName parsed, s_typeNameParseOptions))
2123
{
2224
typeWasNotFoundInAssemblyNorBaseLibrary = false;
2325
return null;

src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj

+4-27
Original file line numberDiff line numberDiff line change
@@ -198,39 +198,12 @@
198198
<Compile Include="..\..\Common\TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs">
199199
<Link>Utilities\CustomAttributeTypeNameParser.cs</Link>
200200
</Compile>
201-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\HexConverter.cs">
202-
<Link>Utilities\HexConverter.cs</Link>
203-
</Compile>
204-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameFormatter.cs">
205-
<Link>Utilities\AssemblyNameFormatter.cs</Link>
206-
</Compile>
207-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameParser.cs">
208-
<Link>Utilities\AssemblyNameParser.cs</Link>
209-
</Compile>
210-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\AssemblyNameInfo.cs">
211-
<Link>Utilities\AssemblyNameInfo.cs</Link>
212-
</Compile>
213-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeName.cs">
214-
<Link>Utilities\TypeName.cs</Link>
215-
</Compile>
216-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParser.cs">
217-
<Link>Utilities\TypeNameParser.cs</Link>
218-
</Compile>
219-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserHelpers.cs">
220-
<Link>Utilities\TypeNameParserHelpers.cs</Link>
221-
</Compile>
222-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserOptions.cs">
223-
<Link>Utilities\TypeNameParserOptions.cs</Link>
224-
</Compile>
225201
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\TypeNameParser.Helpers.cs">
226202
<Link>Utilities\CustomAttributeTypeNameParser.Helpers</Link>
227203
</Compile>
228204
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Text\ValueStringBuilder.cs">
229205
<Link>Utilities\ValueStringBuilder.cs</Link>
230206
</Compile>
231-
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Text\ValueStringBuilder.AppendSpanFormattable.cs">
232-
<Link>Utilities\ValueStringBuilder.AppendSpanFormattable.cs</Link>
233-
</Compile>
234207
<Compile Include="..\..\Common\TypeSystem\Common\Utilities\GCPointerMap.Algorithm.cs">
235208
<Link>Utilities\GCPointerMap.Algorithm.cs</Link>
236209
</Compile>
@@ -741,6 +714,10 @@
741714
<AdditionalFiles Include="BannedSymbols.txt" />
742715
</ItemGroup>
743716

717+
<ItemGroup>
718+
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
719+
</ItemGroup>
720+
744721
<ItemGroup>
745722
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'">
746723
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/libraries/Common/src/System/Reflection/Metadata/AssemblyNameInfo.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace System.Reflection.Metadata
2121
/// It's a more lightweight, immutable version of <seealso cref="AssemblyName"/> that does not pre-allocate <seealso cref="System.Globalization.CultureInfo"/> instances.
2222
/// </remarks>
2323
[DebuggerDisplay("{FullName}")]
24-
#if SYSTEM_PRIVATE_CORELIB
25-
internal
26-
#else
24+
#if SYSTEM_REFLECTION_METADATA
2725
public
26+
#else
27+
internal
2828
#endif
2929
sealed class AssemblyNameInfo
3030
{
@@ -182,11 +182,7 @@ public AssemblyName ToAssemblyName()
182182
public static AssemblyNameInfo Parse(ReadOnlySpan<char> assemblyName)
183183
=> TryParse(assemblyName, out AssemblyNameInfo? result)
184184
? result!
185-
#if SYSTEM_REFLECTION_METADATA || SYSTEM_PRIVATE_CORELIB
186185
: throw new ArgumentException(SR.InvalidAssemblyName, nameof(assemblyName));
187-
#else // tools that reference this file as a link
188-
: throw new ArgumentException("The given assembly name was invalid.", nameof(assemblyName));
189-
#endif
190186

191187
/// <summary>
192188
/// Tries to parse a span of characters into an assembly name.

src/libraries/Common/src/System/Reflection/Metadata/TypeName.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
namespace System.Reflection.Metadata
1717
{
1818
[DebuggerDisplay("{AssemblyQualifiedName}")]
19-
#if SYSTEM_PRIVATE_CORELIB
20-
internal
21-
#else
19+
#if SYSTEM_REFLECTION_METADATA
2220
public
21+
#else
22+
internal
2323
#endif
2424
sealed class TypeName
2525
{

src/libraries/Common/src/System/Reflection/Metadata/TypeNameParser.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ namespace System.Reflection.Metadata
1717
[DebuggerDisplay("{_inputString}")]
1818
internal ref struct TypeNameParser
1919
{
20-
private static readonly TypeNameParseOptions _defaults = new();
20+
private static readonly TypeNameParseOptions s_defaults = new();
21+
2122
private readonly bool _throwOnError;
2223
private readonly TypeNameParseOptions _parseOptions;
2324
private ReadOnlySpan<char> _inputString;
@@ -26,7 +27,7 @@ private TypeNameParser(ReadOnlySpan<char> name, bool throwOnError, TypeNameParse
2627
{
2728
_inputString = name;
2829
_throwOnError = throwOnError;
29-
_parseOptions = options ?? _defaults;
30+
_parseOptions = options ?? s_defaults;
3031
}
3132

3233
internal static TypeName? Parse(ReadOnlySpan<char> typeName, bool throwOnError, TypeNameParseOptions? options = default)
@@ -50,7 +51,7 @@ private TypeNameParser(ReadOnlySpan<char> name, bool throwOnError, TypeNameParse
5051
{
5152
if (throwOnError)
5253
{
53-
if (recursiveDepth >= parser._parseOptions.MaxNodes)
54+
if (parser._parseOptions.IsMaxDepthExceeded(recursiveDepth))
5455
{
5556
ThrowInvalidOperation_MaxNodesExceeded(parser._parseOptions.MaxNodes);
5657
}
@@ -249,7 +250,7 @@ private bool TryParseAssemblyName(ref AssemblyNameInfo? assemblyName)
249250

250251
private bool TryDive(ref int depth)
251252
{
252-
if (depth >= _parseOptions.MaxNodes)
253+
if (_parseOptions.IsMaxDepthExceeded(depth))
253254
{
254255
return false;
255256
}

0 commit comments

Comments
 (0)