Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change S.R.M.TypeName to be consumed from System.Reflection.Metadata package #101666

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,43 +282,43 @@
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>26f8c30340764cfa7fa9090dc01a36c222bf09c1</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="9.0.0-preview.4.24219.3">
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="runtime.native.System.IO.Ports" Version="9.0.0-preview.4.24219.3">
<Dependency Name="runtime.native.System.IO.Ports" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.ILAsm" Version="9.0.0-preview.4.24219.3">
<Dependency Name="Microsoft.NETCore.ILAsm" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Sdk.IL" Version="9.0.0-preview.4.24219.3">
<Dependency Name="Microsoft.NET.Sdk.IL" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="System.Text.Json" Version="9.0.0-preview.4.24219.3">
<Dependency Name="System.Text.Json" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.runtime.linux-x64" Version="9.0.0-preview.4.24219.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.runtime.linux-x64" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
<SourceBuild RepoName="runtime" ManagedOnly="false" />
</Dependency>
<Dependency Name="Microsoft.DotNet.ILCompiler" Version="9.0.0-preview.4.24219.3">
<Dependency Name="Microsoft.DotNet.ILCompiler" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="System.Reflection.Metadata" Version="9.0.0-preview.4.24219.3">
<Dependency Name="System.Reflection.Metadata" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="System.Reflection.MetadataLoadContext" Version="9.0.0-preview.4.24219.3">
<Dependency Name="System.Reflection.MetadataLoadContext" Version="9.0.0-preview.4.24227.6">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>56610095196ac12a397b1acd00835db4d86849b9</Sha>
<Sha>b8fe1d0ccb60926d6e7ef5d42e2398c178c9ee5c</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24224.1">
<Uri>https://github.com/dotnet/xharness</Uri>
Expand Down
14 changes: 7 additions & 7 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@
<!-- NuGet dependencies -->
<NuGetBuildTasksPackVersion>6.0.0-preview.1.102</NuGetBuildTasksPackVersion>
<!-- Installer dependencies -->
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.0-preview.4.24219.3</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreAppRuntimewinx64Version>9.0.0-preview.4.24227.6</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftExtensionsDependencyModelVersion>6.0.0</MicrosoftExtensionsDependencyModelVersion>
<!-- ILAsm dependencies -->
<MicrosoftNETCoreILAsmVersion>9.0.0-preview.4.24219.3</MicrosoftNETCoreILAsmVersion>
<MicrosoftNETCoreILAsmVersion>9.0.0-preview.4.24227.6</MicrosoftNETCoreILAsmVersion>
<!-- Libraries dependencies -->
<MicrosoftBclAsyncInterfacesVersion>6.0.0</MicrosoftBclAsyncInterfacesVersion>
<MicrosoftBclHashCodeVersion>1.1.1</MicrosoftBclHashCodeVersion>
Expand All @@ -119,19 +119,19 @@
<SystemDrawingCommonVersion>8.0.0</SystemDrawingCommonVersion>
<SystemIOFileSystemAccessControlVersion>5.0.0</SystemIOFileSystemAccessControlVersion>
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
<SystemReflectionMetadataVersion>9.0.0-preview.4.24219.3</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>9.0.0-preview.4.24219.3</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionMetadataVersion>9.0.0-preview.4.24227.6</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>9.0.0-preview.4.24227.6</SystemReflectionMetadataLoadContextVersion>
<SystemSecurityAccessControlVersion>6.0.0</SystemSecurityAccessControlVersion>
<SystemSecurityCryptographyCngVersion>5.0.0</SystemSecurityCryptographyCngVersion>
<SystemSecurityCryptographyOpenSslVersion>5.0.0</SystemSecurityCryptographyOpenSslVersion>
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
<SystemSecurityPermissionsVersion>7.0.0</SystemSecurityPermissionsVersion>
<SystemTextJsonVersion>9.0.0-preview.4.24219.3</SystemTextJsonVersion>
<SystemTextJsonVersion>9.0.0-preview.4.24227.6</SystemTextJsonVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemThreadingAccessControlVersion>7.0.0</SystemThreadingAccessControlVersion>
<SystemThreadingTasksExtensionsVersion>4.5.4</SystemThreadingTasksExtensionsVersion>
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<runtimenativeSystemIOPortsVersion>9.0.0-preview.4.24219.3</runtimenativeSystemIOPortsVersion>
<runtimenativeSystemIOPortsVersion>9.0.0-preview.4.24227.6</runtimenativeSystemIOPortsVersion>
<!-- Keep toolset versions in sync with dotnet/msbuild and dotnet/sdk -->
<SystemCollectionsImmutableToolsetVersion>8.0.0</SystemCollectionsImmutableToolsetVersion>
<SystemTextJsonToolsetVersion>8.0.0</SystemTextJsonToolsetVersion>
Expand Down Expand Up @@ -210,7 +210,7 @@
<!-- Mono Cecil -->
<MicrosoftDotNetCecilVersion>0.11.4-alpha.24222.1</MicrosoftDotNetCecilVersion>
<!-- ILCompiler -->
<MicrosoftDotNetILCompilerVersion>9.0.0-preview.4.24219.3</MicrosoftDotNetILCompilerVersion>
<MicrosoftDotNetILCompilerVersion>9.0.0-preview.4.24227.6</MicrosoftDotNetILCompilerVersion>
<!-- ICU -->
<MicrosoftNETCoreRuntimeICUTransportVersion>9.0.0-preview.5.24223.2</MicrosoftNETCoreRuntimeICUTransportVersion>
<!-- MsQuic -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ namespace System.Reflection
{
internal partial struct TypeNameParser
{
private static readonly TypeNameParseOptions s_typeNameParseOptions = new() { MaxNodes = int.MaxValue };

private ModuleDesc _module;
private bool _throwIfNotFound;
private Func<ModuleDesc, string, MetadataType> _canonResolver;

public static TypeDesc ResolveType(ModuleDesc module, string name, bool throwIfNotFound,
Func<ModuleDesc, string, MetadataType> canonResolver)
{
if (!TypeName.TryParse(name.AsSpan(), out TypeName parsed))
if (!TypeName.TryParse(name.AsSpan(), out TypeName parsed, s_typeNameParseOptions))
{
ThrowHelper.ThrowTypeLoadException(name, module);
}
Expand Down
24 changes: 0 additions & 24 deletions src/coreclr/tools/ILVerification/ILVerification.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,6 @@
<Compile Include="$(ToolsCommonPath)TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs">
<Link>Utilities\CustomAttributeTypeNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\HexConverter.cs">
<Link>Utilities\HexConverter.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameFormatter.cs">
<Link>Utilities\AssemblyNameFormatter.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameParser.cs">
<Link>Utilities\AssemblyNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\AssemblyNameInfo.cs">
<Link>Utilities\Metadata\AssemblyNameInfo.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeName.cs">
<Link>Utilities\TypeName.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserOptions.cs">
<Link>Utilities\TypeNameParserOptions.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParser.cs">
<Link>Utilities\TypeNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserHelpers.cs">
<Link>Utilities\TypeNameParserHelpers.cs</Link>
</Compile>
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<Link>System\Diagnostics\CodeAnalysis\UnconditionalSuppressMessageAttribute.cs</Link>
</Compile>
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/ILVerify/ILVerify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
<PackageReference Include="System.CommandLine" Version="$(SystemCommandLineVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace System.Reflection
{
internal partial struct TypeNameParser
{
private static readonly TypeNameParseOptions s_typeNameParseOptions = new() { MaxNodes = int.MaxValue };

private TypeSystemContext _context;
private ModuleDesc _callingModule;
private List<ModuleDesc> _referencedModules;
Expand All @@ -17,7 +19,7 @@ internal partial struct TypeNameParser
public static TypeDesc ResolveType(string name, ModuleDesc callingModule,
TypeSystemContext context, List<ModuleDesc> referencedModules, out bool typeWasNotFoundInAssemblyNorBaseLibrary)
{
if (!TypeName.TryParse(name, out TypeName parsed))
if (!TypeName.TryParse(name, out TypeName parsed, s_typeNameParseOptions))
{
typeWasNotFoundInAssemblyNorBaseLibrary = false;
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,39 +198,12 @@
<Compile Include="..\..\Common\TypeSystem\Common\Utilities\CustomAttributeTypeNameParser.cs">
<Link>Utilities\CustomAttributeTypeNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\HexConverter.cs">
<Link>Utilities\HexConverter.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameFormatter.cs">
<Link>Utilities\AssemblyNameFormatter.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\AssemblyNameParser.cs">
<Link>Utilities\AssemblyNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\AssemblyNameInfo.cs">
<Link>Utilities\AssemblyNameInfo.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeName.cs">
<Link>Utilities\TypeName.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParser.cs">
<Link>Utilities\TypeNameParser.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserHelpers.cs">
<Link>Utilities\TypeNameParserHelpers.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\Metadata\TypeNameParserOptions.cs">
<Link>Utilities\TypeNameParserOptions.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Reflection\TypeNameParser.Helpers.cs">
<Link>Utilities\CustomAttributeTypeNameParser.Helpers</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Text\ValueStringBuilder.cs">
<Link>Utilities\ValueStringBuilder.cs</Link>
</Compile>
<Compile Include="$(LibrariesProjectRoot)\Common\src\System\Text\ValueStringBuilder.AppendSpanFormattable.cs">
<Link>Utilities\ValueStringBuilder.AppendSpanFormattable.cs</Link>
</Compile>
<Compile Include="..\..\Common\TypeSystem\Common\Utilities\GCPointerMap.Algorithm.cs">
<Link>Utilities\GCPointerMap.Algorithm.cs</Link>
</Compile>
Expand Down Expand Up @@ -741,6 +714,10 @@
<AdditionalFiles Include="BannedSymbols.txt" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ namespace System.Reflection.Metadata
/// It's a more lightweight, immutable version of <seealso cref="AssemblyName"/> that does not pre-allocate <seealso cref="System.Globalization.CultureInfo"/> instances.
/// </remarks>
[DebuggerDisplay("{FullName}")]
#if SYSTEM_PRIVATE_CORELIB
internal
#else
#if SYSTEM_REFLECTION_METADATA
public
#else
internal
#endif
sealed class AssemblyNameInfo
{
Expand Down Expand Up @@ -182,11 +182,7 @@ public AssemblyName ToAssemblyName()
public static AssemblyNameInfo Parse(ReadOnlySpan<char> assemblyName)
=> TryParse(assemblyName, out AssemblyNameInfo? result)
? result!
#if SYSTEM_REFLECTION_METADATA || SYSTEM_PRIVATE_CORELIB
: throw new ArgumentException(SR.InvalidAssemblyName, nameof(assemblyName));
#else // tools that reference this file as a link
: throw new ArgumentException("The given assembly name was invalid.", nameof(assemblyName));
#endif

/// <summary>
/// Tries to parse a span of characters into an assembly name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
namespace System.Reflection.Metadata
{
[DebuggerDisplay("{AssemblyQualifiedName}")]
#if SYSTEM_PRIVATE_CORELIB
internal
#else
#if SYSTEM_REFLECTION_METADATA
public
#else
internal
#endif
sealed class TypeName
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace System.Reflection.Metadata
[DebuggerDisplay("{_inputString}")]
internal ref struct TypeNameParser
{
private static readonly TypeNameParseOptions _defaults = new();
private static readonly TypeNameParseOptions s_defaults = new();

private readonly bool _throwOnError;
private readonly TypeNameParseOptions _parseOptions;
private ReadOnlySpan<char> _inputString;
Expand All @@ -26,7 +27,7 @@ private TypeNameParser(ReadOnlySpan<char> name, bool throwOnError, TypeNameParse
{
_inputString = name;
_throwOnError = throwOnError;
_parseOptions = options ?? _defaults;
_parseOptions = options ?? s_defaults;
}

internal static TypeName? Parse(ReadOnlySpan<char> typeName, bool throwOnError, TypeNameParseOptions? options = default)
Expand All @@ -50,7 +51,7 @@ private TypeNameParser(ReadOnlySpan<char> name, bool throwOnError, TypeNameParse
{
if (throwOnError)
{
if (recursiveDepth >= parser._parseOptions.MaxNodes)
if (parser._parseOptions.IsMaxDepthExceeded(recursiveDepth))
{
ThrowInvalidOperation_MaxNodesExceeded(parser._parseOptions.MaxNodes);
}
Expand Down Expand Up @@ -249,7 +250,7 @@ private bool TryParseAssemblyName(ref AssemblyNameInfo? assemblyName)

private bool TryDive(ref int depth)
{
if (depth >= _parseOptions.MaxNodes)
if (_parseOptions.IsMaxDepthExceeded(depth))
{
return false;
}
Expand Down
Loading
Loading