Skip to content

Conversation

@gurustron
Copy link
Contributor

@gurustron gurustron commented Nov 29, 2023

  1. Make snippets runnable
  2. I would argue changing the static field type is more real life fix because you can an actually do something like:
class C1
{
    private static readonly string StaticField = "Format one value: {0}";

    static void Main()
    {
        _ = string.Format(null, CompositeFormat.Parse(StaticField), 42);

        StringBuilder sb = new();
        sb.AppendFormat(null, CompositeFormat.Parse(StaticField), 42);
    }
}

Which obviously makes the warning to go away but does not actually cover the underlying issue.


Internal previews

📄 File 🔗 Preview link
docs/fundamentals/code-analysis/quality-rules/ca1863.md CA1863: Use 'CompositeFormat'

@gurustron gurustron requested a review from gewarren as a code owner November 29, 2023 12:35
@dotnet-bot dotnet-bot added this to the November 2023 milestone Nov 29, 2023
@ghost ghost added the community-contribution Indicates PR is created by someone from the .NET community. label Nov 29, 2023
Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gurustron

@gewarren gewarren merged commit b7e8a65 into dotnet:main Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants