Skip to content

Ensure no component embed the Index/Range source code and reference Microsoft.Bcl.Memory package instead #104308

@tarekgh

Description

@tarekgh

Description

We have poly filled the Index and Range types to make them work on ns2.0 and netfx. This issue is tracking to ensure all components we build in .NET shouldn't carry its own version of these types and instead should be referencing Microsoft.Bcl.Memory package.

Searching the sources, looks only ComInterfaceGenerator.csproj is using the Index source file. To remove this dependency, we will need to have this project depend on Microsoft.Bcl.Memory and ensure Microsoft.Bcl.Memory library is included in microsoft.netcore.app.ref pack too under the analyzers\dotnet\cs folder. Unfortunately, the current infrastructure does not allow to bin pace such dependency.

Here are the things need to be done:

  • Remove compiling the Index source code in
    <Compile Include="$(CoreLibSharedDir)System\Index.cs" Link="Common\System\Index.cs" />
  • Let ComInterfaceGenerator.csproj reference the project of Microsoft.Bcl.Memory.
  • Delete the lines
    <ItemGroup Condition="'$(IncludeIndexRangeTypes)' == 'true' and '$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
    <Compile Include="$(CoreLibSharedDir)System\Index.cs" Link="System\Index.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Range.cs" Link="System\Range.cs" />
    <Compile Include="$(CoreLibSharedDir)System\Numerics\Hashing.cs" Link="System\Numerics\Hashing.cs" />
    </ItemGroup>
  • Ensure when building Microsoft.Bcl.Memory is bin placed inside the microsoft.netcore.app.ref package under analyzers\dotnet\cs folder and next to the ComInterfaceGenerator lib.
  • Edit Index and Range to remove the #if there and only keep public specifier.
  • edit Microsoft.Bcl.Memory.csproj from library src folder to remove the line <DefineConstants>MICROSOFT_BCL_MEMORY;$(DefineConstants)</DefineConstants>
  • Build the whole tree and validate tests of the com interface and Microsoft.Bcl.Memory pass and the package microsoft.netcore.app.ref include Microsoft.Bcl.Memory library.

Reproduction Steps

Com interface source gen is including the Index.cs in the project.

Expected behavior

No component in .NET is embedding the Index/Range sources.

Actual behavior

Com interface source gen carries a copy of the Index type code.

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions