dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.07k stars 1.73k forks source link

SecureStorage bool value #5267

Open jrahma opened 2 years ago

jrahma commented 2 years ago

Description

Currently, we can only set a string value to the SecureStorage but many times we want to set a true/false without having to Convert it every time just to get the bool from the string.

Public API Changes

public static System.Threading.Tasks.Task SetAsync (string key, string/bool value);

Intended Use-Case

SecureStorage.SetAsync("EmailAddress", "my@domain.com");
SecureStorage.SetAsync("IsMember", true);
janseris commented 2 years ago

Blazor already supports this so in general statically typed (even if serialized to intermediate format just as in Blazor - it has to use JSON because for browsers, it must be implemented using Javascript interop) would be nice

mattleibow commented 1 year ago

This is partially because some underlying platforms only support strings, but no reason to not have some helper extension methods.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Alirexaa commented 1 year ago

Hey, @jfversluis I don't have any experience in contributing to the open-source community, but I like to work on this issue. so if it's okay, is there anything specific that I should know?

jfversluis commented 1 year ago

Hey @Alirexaa that is cool, thanks for your interest in contributing to .NET MAUI! You probably might want to have a look here.

Other than that, before you spend a lot of time you might want to check if your proposed solution is one we can agree with. You can either do that here, or create a new issue with a bit more of a detailed specification. Try to describe what you want to do and why along with some (pseudo)code on what the public API would look like (what are the methods that people call when using this) and code how people would be using this to show how it makes their lives easier.

I guess in this case some helper methods like Matthew suggested would be fine for this. Looking forward to seeing your contributions!

Alirexaa commented 1 year ago

Hey @Alirexaa that is cool, thanks for your interest in contributing to .NET MAUI! You probably might want to have a look here.

Other than that, before you spend a lot of time you might want to check if your proposed solution is one we can agree with. You can either do that here, or create a new issue with a bit more of a detailed specification. Try to describe what you want to do and why along with some (pseudo)code on what the public API would look like (what are the methods that people call when using this) and code how people would be using this to show how it makes their lives easier.

I guess in this case some helper methods like Matthew suggested would be fine for this. Looking forward to seeing your contributions!

I think it a good choice to add some extension methods for SecureStorage that has one generic param as a type of value to set value in storage by using serialization value to JSON and using deserialization to get value from storage.

the public API signature would look like this :

public static System.Threading.Tasks.Task SetAsync<TValue>(string key, TValue value);

public static System.Threading.Tasks.Task<TValue?> GetAsync<TValue>(string key);