Skip to content

BCL type shadowed in Microsoft.Extensions.DependencyModel package #129881

Description

@YoshiRulz

It looks like the previous issue #34420 was closed because it wasn't causing any problems. Well I've found a problem.

Write to repro.app.cs and dotnet run repro.app.cs:

#:property TargetFramework=net10.0
#:property ImplicitUsings=false
// transitively imports Microsoft.Extensions.DependencyModel
//#:package Silk.NET.OpenGL@2.23.0

using System;
using System.Collections.Generic;

Dictionary<string, int> dict = new() { ["a"] = 3 };
Console.WriteLine(dict.GetValueOrDefault("a", 2));
Console.WriteLine(CollectionExtensions.GetValueOrDefault(dict, "b", 2));

Then uncomment the import and try running again.

repro.app.cs(11,19): error CS0433: The type 'CollectionExtensions' exists in both 'Microsoft.Extensions.DependencyModel, Version=9.0.0.9, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'System.Collections, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions