Skip to content

[Serialization][Configuration] Unable to get NamedOptions and ValueTuples Values from appsettings.sampledata.json via JsonSerialization #2769

Closed

Description

@DevTKSS

Current behavior

While the DI is able to resolve the named Service "CodeSampleService" in my App.xaml.cs (linked the commit where I changed it to a Generic Service as Workaround so you can see the diff what I changed to make it work as minimum), set up with NamedOptions, the CodeSampleOption defined by using a List<(int,int)> which seems to be a known issue for JsonSerialization which seems not to be expected to get solved any time soon :( ... (maybe Uno has a Extension for that which I do not know?) and CodeSampleOptionsConfiguration which should Serialialize as Dictionary<string,CodeSampleOption> by using a "SomeIDName" : {... in json instead of unnamed object like I changed it to now, are not available at runtime.

Expected behavior

It should be able to resolve the configuration when its fed with the JsonTypeInfo like docs teaching from Serialization and show the sampledata > CodeSampleConfiguration> Keys as options to call the sample from storage from.

How to reproduce it (as minimally and precisely as possible)

The Project is here on GitHub:
DevTKSS/DevTKSS.Uno.SampleApps@4f3bf64

(linked the commit where you can still see the Dictionary definition I tryed to use.

The "missing" package you will see if cloning is set to private because its content is filed in this PR #2734
here is the nuget its using

Environment

Visual Studio 2022 Community Edition on Windows

Nuget Package (s):
Directory.Packages.props

    <PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.2.250402" />
    <PackageVersion Include="DevTKSS.Extensions.Uno" Version="1.0.0-preview.1.0.0" />

csproj

...
<UnoFeatures>
    Material;
    Dsp;
    Hosting;
    Toolkit;
    Logging;
    MVUX;
    Configuration;
    Localization;
    Navigation;
    ThemeService;
    Serialization;
    Storage;
</UnoFeatures>
<PropertyGroup/>
<ItemGroup>
    <PackageReference Include="CommunityToolkit.WinUI.Converters" />
    <PackageReference Include="DevTKSS.Extensions.Uno" />
<ItemGroup/>

Package Version(s):

Uno.Sdk 6.0.67

Affected platform(s):

(only target in this project)

  • Skia (Desktop)
  • Build tasks

Visual Studio:

  • 2022 (version: 17.13.6)
  • Visual Studio Code (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

since the logger in the method gets called, I am quite sure, its something to do with the options setup and definition. In Uno.Chefs AppConfig is a second Attribute used Dictionary<string,AppConfig> which makes me think I might miss such thing in my config, but since a second attribute usage is not documented to be optional at all...

Post Edit: I added now some more JsonSerializable Attributes to the CodeSampleOptionContext trying to get it working somehow and turned out, that the Default. the Docs are only telling about, is getting expanded when we are adding more of those attributes. But still the above mentioned Collection types are not possible so far with what I tryed, as you can see in the commits before that in the json file.

Could there be added a documentation or guide to how to handle szenarios where we need multiple things for one Context? Especially I am looking for Limitations that are really applying, because I am just guessing its not possible assuming from the linked bug for example.

Activity

  1. added
    kind/bug
    triage/untriaged
    on May 14, 2025
  2. changed the title [-][Serialization][Configuration] Unable to get Values from appsettings.sampledata.json[/-] [+][Serialization][Configuration] Unable to get NamedOptions and ValueTuples Values from appsettings.sampledata.json via JsonSerialization[/+] on May 18, 2025
  3. added theissue type on Jun 19, 2025
  4. DevTKSS commented on Jul 18, 2025

    @DevTKSS
    ContributorAuthor

    Hoping to get this solved to use it in my Code DevTKSS/DevTKSS.Uno.SampleApps#9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugtriage/untriaged

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions