jamesmontemagno / SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
MIT License
324 stars 80 forks source link

Default value can not be null #67

Closed jb69 closed 7 years ago

jb69 commented 7 years ago

Feature Request:

Latest build no longer allows default values to be null even when that is a valid result for the type.

if (defaultValue == null) { throw new ArgumentNullException ("defaultValue", "Default value can not be null"); }

Please continue to allow default values of null.

jamesmontemagno commented 7 years ago

It never allowed it as terrible things could happen. Now I really don't allow it.

jb69 commented 7 years ago

OK, nice response.

But you code now fails with its own default parameter value is the type of T is a string.

public T GetValueOrDefault<T>(string key, T defaultValue = default(T)) { if(defaultValue == null) { throw new ArgumentNullException(nameof(defaultValue), "Default value can not be null"); }

jamesmontemagno commented 7 years ago

I will revert these changes for now. I will be making drastic changes to this API for 3.0 as the original API was to open and easily misinterpreted.