Skip to content

Update tools to the latest version of System.Reflection.Metadata #101541

@adamsitnik

Description

@adamsitnik

When the SDK version is updated to latest, we are going to need to make some changes to the tools, so they stop referencing the new APIs via links and simply consume latest version of System.Reflection.Metadata package.

Here is the list of things that it will requires

  1. Remove links to files from ILVerification.projitems:
    <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>
    <Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\NullableAttributes.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
    <Link>System\Diagnostics\CodeAnalysis\NullableAttributes.cs</Link>
    </Compile>

    <Compile Include="$(LibrariesProjectRoot)\Common\src\System\Text\ValueStringBuilder.AppendSpanFormattable.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
    <Link>Utilities\ValueStringBuilder.AppendSpanFormattable.cs</Link>
    </Compile>
  2. And from ILCompiler.TypeSystem.csproj:
    <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\Text\ValueStringBuilder.AppendSpanFormattable.cs">
    <Link>Utilities\ValueStringBuilder.AppendSpanFormattable.cs</Link>
    </Compile>
  3. Move all the files from src/libraries/Common/src/System/Reflection/Metadata/*.cs to src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/
  4. Remove #nullable enable from following files:







  5. Change the #if to public for SYSTEM_REFLECTION_METADATA, otherwise internal (https://github.com/dotnet/runtime/pull/100094/files#r1577334880)
    #if SYSTEM_PRIVATE_CORELIB
    internal
    #else
    public
    #endif

    #if SYSTEM_PRIVATE_CORELIB
    internal
    #else
    public
    #endif

    #if SYSTEM_PRIVATE_CORELIB
    internal
    #else
    public
    #endif
  6. Remove #pragma warning disable RS003
    #pragma warning disable RS0030 // TypeSystem does not allow System.Linq, but we need to use System.Linq.ImmutableArrayExtensions.ToArray
  7. Simpify throw helpers by removing unused #if/else/elif blocks:
    #else // tools that reference this file as a link
    : throw new ArgumentException("The given assembly name was invalid.", nameof(assemblyName));
    #endif

    #else // tools that reference this file as a link
    new ArgumentException();
    #endif

    #else // tools that reference this file as a link
    new InvalidOperationException();
    #endif

    #else // tools that reference this file as a link
    new InvalidOperationException();
    #endif
  8. Update comments (remove the tools mentions):
    #else // corelib and tools that reference this file as a link

    #else // corelib and tools that reference this file as a link

    #else // corelib and tools that reference this file as a link

cc @jkotas

Metadata

Metadata

Assignees

Labels

area-Tools-ILVerificationIssues related to ilverify tool and IL verification in general

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions