Skip to content

CustomAttributeTypedArgument.ToString() is missing an open curly #61282

Closed

Description

@romkatv

Description

CustomAttributeTypedArgument.ToString() produces malformed output if the argument is an array.

Reproduction Steps

Console.WriteLine(
    new System.Reflection.CustomAttributeTypedArgument(
        new [] { new System.Reflection.CustomAttributeTypedArgument(0) }));

Expected behavior

new CustomAttributeTypedArgument[1] { 0 }

Actual behavior

new CustomAttributeTypedArgument[1]0 }

Regression?

It's a regression. The bug was introduced after the .NET 5 release: 0c79392#diff-f43b9f98fddac0e7fa971362f6f07f5fc9a3a0a41b485e9df15df87c99d638cb

Known Workarounds

No response

Configuration

Works before 0c79392. Doesn't work after.

Other information

No response

Activity

  1. ghost added
    untriaged
    on Nov 6, 2021
  2. added this to the 6.0.0 milestone on Nov 8, 2021
  3. added and removed
    untriaged
    on Nov 8, 2021
  4. buyaa-n commented on Nov 8, 2021

    @buyaa-n
    Contributor

    It's a regression. The bug was introduced after the .NET 5 release

    Thanks for reporting @romkatv seems it is introduced in 6.0 preview 4

  5. romkatv commented on Nov 8, 2021

    @romkatv
    Author

    seems it is introduced in 6.0 preview 4

    The bug was introduced in 0c79392.

    This should fix it:

    diff --git a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeTypedArgument.cs b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeTypedArgument.cs
    index 18d033b5..d6498fa1 100644
    --- a/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeTypedArgument.cs
    +++ b/src/libraries/System.Private.CoreLib/src/System/Reflection/CustomAttributeTypedArgument.cs
    @@ -68,6 +68,8 @@ internal string ToString(bool typed)
                     result.Append(count.ToString());
                     result.Append(']');
     
    +                result.Append(" { ");
    +
                     for (int i = 0; i < count; i++)
                     {
                         if (i != 0)
  6. buyaa-n commented on Nov 8, 2021

    @buyaa-n
    Contributor

    Right that can fix, or just change that char result.Append(']'); into string result.Append("] { ");, feel free to fix with corresponding unit test

  7. romkatv commented on Nov 8, 2021

    @romkatv
    Author

    feel free to fix with corresponding unit test

    I'll leave it up to the professionals.

  8. added
    help wanted
    on Nov 8, 2021
  9. ghost added
    in-pr
    on Nov 8, 2021
  10. ghost removed
    in-pr
    on Nov 8, 2021
  11. buyaa-n commented on Nov 8, 2021

    @buyaa-n
    Contributor

    Reopening as it needs to be ported into 6.0 CC @jeffhandley

  12. reopened this on Nov 8, 2021
  13. ghost added
    in-pr
    on Nov 8, 2021
  14. removed
    help wanted
    on Nov 8, 2021
  15. ghost removed
    in-pr
    on Nov 12, 2021
  16. buyaa-n commented on Nov 12, 2021

    @buyaa-n
    Contributor

    Fix merged into 6.0

  17. ghost locked as resolved and limited conversation to collaborators on Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions