Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fixed string Join method#8114

Merged
danmoseley merged 1 commit into
dotnet:masterfrom
AlexRadch:AlexRadch-String-Join-Fix-16.11.14
Nov 16, 2016
Merged

Fixed string Join method#8114
danmoseley merged 1 commit into
dotnet:masterfrom
AlexRadch:AlexRadch-String-Join-Fix-16.11.14

Conversation

@AlexRadch
Copy link
Copy Markdown

Fixed string Join(string separator, params object[] values) method.
Calling string.Join(",", null, 1, 2, 3); return empty string but should ",1,2,3".

Fixed string Join(string separator, params object[] values) method.
Calling string.Join(",", null, 1, 2, 3); return empty string but should ",1,2,3".
@danmoseley
Copy link
Copy Markdown
Member

@AlexRadch unfortunately compatibility with the .NET Framework is very important to us, and that returns "" also. I don't think there is good enough reason to break compatibility here even though it presumably isn't doucmented behavior.

@AlexRadch
Copy link
Copy Markdown
Author

AlexRadch commented Nov 15, 2016

@danmosemsft how many programs use this unusual behavior as useful? I think no one.
I think many programs use this Join and in some rare cases can return empty string when should not do it. In other words many programs have erroneous behavior because this method have error and no one use this error as future.
So why .NET Framework still support this bug? And do not fix it?

@jnm2
Copy link
Copy Markdown

jnm2 commented Nov 15, 2016

@danmosemsft I was about to follow this up with, how soon until this fix makes it into full framework? If it has to be quirked, so be it; I seriously hope desktop .NET vNext ships this fix.

@danmoseley
Copy link
Copy Markdown
Member

@jnm2 it looks like the object[] overload of Join has had this bug since it was introduced in 4.0. It seems to me indeed a bug since it's inconsistent with the original string[] overload of Join. Given that I think we might take this change but backporting might take a while. @stephentoub thoughts?

@jnm2
Copy link
Copy Markdown

jnm2 commented Nov 15, 2016

I've already identified two places in the codebase I happen to have open where this bug could cause some very interesting debugging sessions. Even more if I inadvertently switch from an IEnumerable overload to the object[] overload.

@dnfclas
Copy link
Copy Markdown

dnfclas commented Nov 16, 2016

@AlexRadch, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@dnfclas
Copy link
Copy Markdown

dnfclas commented Nov 16, 2016

@AlexRadch, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@danmoseley
Copy link
Copy Markdown
Member

@stephentoub are you comfortable with this change?

@AlexRadch it would need a follow up change in corefx to add a test

@stephentoub
Copy link
Copy Markdown
Member

@stephentoub are you comfortable with this change?

See my comment at https://github.com/dotnet/coreclr/issues/4506#issuecomment-261016448. As long as we port the fix back to desktop (under a quirk I guess, in particular since the behavior is documented) and fix the documentation, I'm ok with it.

@danmoseley danmoseley merged commit b6e5a7f into dotnet:master Nov 16, 2016
@danmoseley
Copy link
Copy Markdown
Member

@AlexRadch in a day or two (supposed to be less) corefx will receive this coreclr change. When that happens could you please submit a PR to add tests to protect this? They will go in here corefx\src\System.Runtime\tests\System\StringTests.cs.

@jamesqo
Copy link
Copy Markdown

jamesqo commented Nov 16, 2016

Nice to see this finally fixed! 🎉

@danmoseley
Copy link
Copy Markdown
Member

We have a PR to update our breaking change guidelines here dotnet/corefx#13718

@AlexRadch
Copy link
Copy Markdown
Author

@danmosemsft I created pull request dotnet/corefx#13747 with fixed tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants