JustArchiNET / ArchiSteamFarm

C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
Apache License 2.0
11.22k stars 1.05k forks source link

Resolve CA1863 by using emitted methods #3264

Closed JustArchi closed 2 months ago

JustArchi commented 2 months ago

Checklist

Enhancement purpose

ASF ignored CA1863 for a while now due to https://github.com/dotnet/roslyn-analyzers/issues/7032. We should aim to resolve it now that we have an option.

Solution

I did the initial part of using the new source generator in https://github.com/JustArchiNET/ArchiSteamFarm/commit/7a8e2091a6bdb59da19c698889bf06bf924a92b5 - EmitFormatMethods="true" can be used for telling source generator to emit format options, afterwards, we need to do a lot of manual labour to replace every single occurance of string.Format() that we have today with the new method.

Why currently available solutions are not sufficient?

Existing string.Format() calls is a lot of boilerplate code, CA1863 is just a cherry on top. Now that there is a better solution to deal with this, we should prefer it.

Can you help us with this enhancement idea?

Yes, I can code the solution myself and send a pull request

Additional info

There are cases where plugins use ASF localization in part to avoid more work on their end - we'll need to #pragma warning disable those places before EmitFormatMethods="true" generates public methods.

https://github.com/dotnet/roslyn-analyzers/pull/7360

JustArchi commented 2 months ago

For plugin creators there is only one visible breaking change, ASF no longer silences CA1863 warning by default: https://github.com/JustArchiNET/ArchiSteamFarm/commit/afa602f9401458316dbb1db026f9b44ba6228ef8

If you need to silence it, you can consider adding it in your own plugin project: Directory.Build.props or .csproj:

    <PropertyGroup>
        <NoWarn>$(NoWarn),CA1863</NoWarn>
    </PropertyGroup>