Skip to content

CS1685 warning when building projects target to net10 #24

@arenekosreal

Description

@arenekosreal

Reproduce steps:

Run this C# code with command like dotnet run /path/to/code.cs:

#:package PathLib@0.9.8

"Hello World".Print();


public static class StringExtensions
{
    public static void Print(this string str) => Console.WriteLine(str);
}

Then you will find compiler gives this warning:
CSC : warning CS1685: The predefined type 'ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'PathLib, Version=0.9.8.0, Culture=neutral, PublicKeyToken=null'

It seems that https://github.com/nemec/pathlib/blob/master/PathLib/Utils/LinqBridge.cs created this attribute, because you were going to use features in the future on old target frameworks. I think you may use https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives to use built-in features if supported?

P.S.: To reproduce this problem, you can also create a new project, add reference to PathLib and run the project like the old days. The result is same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions