Skip to content

.net 5.0 seems to be wrong in detecting zero-terminzted string #45912

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


[severity:It's more difficult to complete my work] [regression] [worked-in:16.7]
The following code:

     class Program
     {
         static void Main(string[] args)
         {
             const string s = "abc";
             const string sz = "abc\0";
    
void Report(string str) 
                 => Console.WriteLine($"\"{str}\" ({str. Length}), zero-terminated: {str. EndsWith("\0")}");
    
Report(s);
             Report(sz);
         }
     }

gives the following output for target framework .net 5.0:

"abc" (3), zero-terminated: True
"abc" (4), zero-terminated: True

For target framework .netcoreapp3.1 the code outputs the following lines:

"abc" (3), zero-terminated: False
"abc" (4), zero-terminated: True

As for me, .net core 3.1 behavior looks correct and .net 5.0 does not.


Original Comments

Feedback Bot on 12/9/2020, 10:13 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions