question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Enhancement] Add appsettings support

See original GitHub issue

Description

It would be useful to have a way for apps to build with different settings (ie: the appsettings.json file pattern already common with Microsoft.Extensions.*).

This is often done like in: https://github.com/dotnet/maui/pull/3872

There’s discussion around removing hosting for .NET 6 MAUI GA: https://github.com/dotnet/maui/issues/4393

In the future we should find a path forward to support this.

One idea is to use a source generator to create the code to inject values from the .json files at build time so that we do not pay a performance price for reading and parsing json files from embedded resources.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:18
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
jamesmontemagnocommented, Feb 26, 2022

Is possible today via -> https://montemagno.com/dotnet-maui-appsettings-json-configuration/ however some startup performance considerations with this method.

1reaction
Ghevicommented, Feb 1, 2023

I don’t know if it’s already included, but can you also consider supporting IOptionsMonitor/IOptionsSnapshot? I have a scenario where I need to reload settings at runtime, I understand it’s something not many people have to do, but if possible it would be awesome. Is there a way to do this at the moment? The best way i found is:

   configuration["MyOptions"] = JsonSerializer.Serializer(new MyOptions { value = "new value" });
   (configuration as IConfigurationRoot).Reload();

and subscribe with the reload token of IConfiguration in the services where i need those options.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration in ASP.NET Core
Learn how to use the Configuration API to configure AppSettings in an ASP.NET Core app.
Read more >
A Better Way to Inject AppSettings in Asp.NET Core
To do this, all you need to do is set it up as a service on your Startup.cs file. Startup.cs has a Configuration...
Read more >
ASP.NET Core appsettings.json update in code
The way I address this issue is by adding an "override" property is stored in a memory cache. So for example, my application...
Read more >
Keeping Configuration Settings in Memory
Typically, you'll retrieve your settings in your project's Startup class (in the Startup.cs file), specifically in the class's ConfigureServices ...
Read more >
Using appsettings.json instead of web.config in .NET Core ...
This is a simple post outlining the steps required to quickly get up and running with configuration files in .NET Core applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found