Improve PaddingConverter CreateInstance implementation#2679
Improve PaddingConverter CreateInstance implementation#2679RussKie merged 2 commits intodotnet:masterfrom
Conversation
|
I think this is a sensible proposal. On a side note, a number of |
|
I'm curious, is this reachable at all? catch (NullReferenceException nullRef)
{
throw new ArgumentException(SR.PropertyValueInvalidEntry, nameof(propertyValues), nullRef);
} |
You get this instead of a typecast exception when a value is null; also values are null for missing keys when the caller uses a |
|
Updated the tests. I think the existing tests (with updated expectations) already cover the modified code paths sufficiently. |
Codecov Report
@@ Coverage Diff @@
## master #2679 +/- ##
===================================================
+ Coverage 57.59523% 58.15824% +0.56301%
===================================================
Files 1235 1240 +5
Lines 418368 423008 +4640
Branches 38816 38852 +36
===================================================
+ Hits 240960 246014 +5054
+ Misses 172035 171620 -415
- Partials 5373 5374 +1
|
|
Thank you |
Fixes #2677
Proposed changes
GetCreateInstanceSupportedreturns true for a null context. Also every other implementation of CreateInstance I could find in WinForms and System.Drawing supports a null context, so PaddingConverter is an outlier.Regression?
Risk
Before
PaddingConverter.CreateInstance(null, properties)throws an exception even thoughPaddingConverter.GetCreateInstanceSupported(null)returns trueAfter
PaddingConverter.CreateInstance(null, properties)creates an instance based on the given properties like any other TypeConverter defined in WinForms and System.DrawingTest methodology
Microsoft Reviewers: Open in CodeFlow