Skip to content

Duplicate reference detection should only consider names (not versions) #25509

@jcouv

Description

@jcouv

This test should have triggered the duplicate detection on desktop but didn't.

        [Fact]
        public void TestDynamic()
        {
            var source = @"
public class C
{
    public static void Main()
    {
        dynamic d1 = 1;
        dynamic d2 = 2;
        System.Console.Write($""{(d1, 2) == (1, d2)} "");
        System.Console.Write($""{(d1, 2) != (1, d2)} "");

        System.Console.Write($""{(d1, 20) == (10, d2)} "");
        System.Console.Write($""{(d1, 20) != (10, d2)} "");
    }
}";
            var comp = CreateCompilation(source, references: new[] { CSharpRef, SystemCoreRef }, options: TestOptions.DebugExe);
            comp.VerifyDiagnostics();
            CompileAndVerify(comp, expectedOutput: "True False False True");
        }
        public static ImmutableArray<MetadataReference> GetReferences(TargetFramework tf, IEnumerable<MetadataReference> additionalReferences)
        {
            var references = GetReferences(tf);
            if (additionalReferences == null)
            {
                return references;
            }

            foreach (var r in additionalReferences)
            {
                if (references.Contains(r))
                {
                    throw new Exception($"Duplicate reference detected {r.Display}");
                }
            }

            return references.AddRange(additionalReferences);
        }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions