Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Expose and test (I)Dictionary.GetValueOrDefault #16605

Merged
merged 2 commits into from
Mar 3, 2017
Merged

Expose and test (I)Dictionary.GetValueOrDefault #16605

merged 2 commits into from
Mar 3, 2017

Conversation

hughbe
Copy link

@hughbe hughbe commented Mar 2, 2017

Running msbuild src\System.Collections\src\System.Collections.csproj /p:TargetGroup=uapaot /p:BaselineAllApiCompatError=true doesn't seem to change anything but I hope this passes CI

Fixes #3482

}

TValue value;
if(dictionary.TryGetValue(key, out value))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: space after opening paren

return value;
}

return defaultValue;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd personally have written this as

return dictionary.TryGetValue(key, out value) ? value : defaultValue;

but what you have is fine.

return value;
}

return defaultValue;
Copy link
Member

Choose a reason for hiding this comment

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

Same nits

Assert.Throws<ArgumentNullException>("dictionary", () => dictionary.GetValueOrDefault("key", "value"));
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It'd be good to test with some other concrete type beyond Dictionary<TKey,TValue> as well.

Copy link
Author

@hughbe hughbe Mar 3, 2017

Choose a reason for hiding this comment

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

Fixed, used SortedDictionary

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks, @hughbe. LGTM once CI is green.

@hughbe
Copy link
Author

hughbe commented Mar 2, 2017

Addressed all your feedback, thanks!

@@ -0,0 +1,4 @@
Compat issues with assembly System.Collections:
Copy link
Member

@jkotas jkotas Mar 2, 2017

Choose a reason for hiding this comment

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

This should not be a universal ApiCompatBaseline.txt. It should be specific to just uap (ApiCompatBaseline.uapaot.txt)

@karelz
Copy link
Member

karelz commented Mar 2, 2017

Thank you for your fix @hughbe! Really appreciate your help.
Please ping the issues when you grab them, so that we can assign them to you ...

Copy link
Member

@safern safern left a comment

Choose a reason for hiding this comment

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

Just fix what @jkotas pointed out. Other than that LGTM!

Thanks for helping with this @hughbe

Add APICompatBaseline
@stephentoub stephentoub merged commit d622dd4 into dotnet:master Mar 3, 2017
@hughbe hughbe deleted the getvalueordefault-expose branch March 3, 2017 13:00
@karelz karelz modified the milestone: 2.0.0 Mar 6, 2017
@chester89
Copy link

@karelz did this method make it to 4.7.2? Looks like it should, but MSDN says otherwise

@karelz
Copy link
Member

karelz commented Jan 19, 2019

It was actually reverted back - see PR #17917.
There are extension methods instead in CollectionExtensions. They didn't make it into .NET Framework. We do not have plans to add them there.

@chester89
Copy link

I see. Thanks for help

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Expose and test (I)Dictionary.GetValueOrDefault

* Address PR feedback

Add APICompatBaseline


Commit migrated from dotnet/corefx@d622dd4
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants