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.

fix: [ConfigurationGenerator not found] in [program.cs]

See original GitHub issue

🐛 Bug Report

  1. ConfigurationGenerator not found
  2. Icon not rendered in output.

💻 Repro or Code Sample

Program.cs

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using GroupVaultClient;
using Blazored.SessionStorage;
using GroupVaultClient.Helper;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.IdentityModel.Logging;
using Microsoft.Fast.Components.FluentUI;
using Blazored.LocalStorage;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddHttpClient();
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7161/api/") });
builder.Services.AddBlazoredSessionStorage();
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddScoped<AppAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(sp => sp.GetRequiredService<AppAuthenticationStateProvider>());
builder.Services.AddFluentUIComponents(options =>
{
    options.HostingModel = BlazorHostingModel.WebAssembly;
    options.IconConfiguration = ConfigurationGenerator.GetIconConfiguration();
    options.EmojiConfiguration = ConfigurationGenerator.GetEmojiConfiguration();
});
builder.Services.AddAuthorizationCore();

await builder.Build().RunAsync();

.csproj file

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
  </PropertyGroup>

  <PropertyGroup>
	<PublishFluentIconAssets>true</PublishFluentIconAssets>
	<FluentIconSizes>10,12,16,20,24,28,32,48</FluentIconSizes>
	<FluentIconVariants>Filled,Regular</FluentIconVariants>
	<PublishFluentEmojiAssets>false</PublishFluentEmojiAssets>
	<FluentEmojiGroups>Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
	<FluentEmojiStyles>Color,Flat,HighContrast</FluentEmojiStyles>
</PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.10" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.10" PrivateAssets="all" />
    <PackageReference Include="Blazored.SessionStorage" Version="2.3.0" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.21" />
    <PackageReference Include="Microsoft.CodeAnalysis" Version="4.6.0" />
    <PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.4.2" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.1" />
  </ItemGroup>

  <ItemGroup>
    <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
  </ItemGroup>

</Project>

MainLayout.razor

@inherits LayoutComponentBase
@using Microsoft.Fast.Components.FluentUI.DesignTokens
@inject ILocalStorageService _localstorage;


<PageTitle>fluenttest</PageTitle>

<div class="container">
    <FluentDesignSystemProvider AccentBaseColor="#0078D7" BaseLayerLuminance="baseLayerLuminance" id="designProvider" class="designProvider" style="min-height: 100% !important;">
        <div class="siteheader">
            <div class="headerHeadline">
                <h3>GroupVault</h3>
            </div>            
            <div class="headerLinksContainer">
                <a href="/">Home</a>
                <a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
            </div>
            <div style="width:100%;display:flex;align-items: end;justify-content: end;margin-right:15px;">
                <div>
                    <span style="margin-right:10px;"><FluentIcon Slot="start" Name="@modeIcon" Size="@IconSize.Size16" Variant="@IconVariant.Filled" Color="@Color.Accent"/></span>
                    <FluentSwitch @bind-Value=darkMode @onclick="changeColorMode"></FluentSwitch>
                </div>
            </div>
        </div>
        <div class="main">
            <div class="navigation">
                <NavMenu />
            </div>

            <div class="content">
                <main>
                    <article class="px-4">                       
                        <ErrorBoundary>
                            <ChildContent>
                                
                                @Body
                            </ChildContent>
                            <ErrorContent Context="ex">
                                 <p class="error">@ex.Message</p>
                            </ErrorContent>
                        </ErrorBoundary>
                    </article>
                </main>
            </div>
        </div></FluentDesignSystemProvider>
    </div>

    @code {
        private float baseLayerLuminance {get;set;} = 100;
        private bool darkMode {get;set;} = false;
        private string modeIcon = FluentIcons.WeatherSunny;

        protected override async Task OnParametersSetAsync()
        {

                string dm = await _localstorage.GetItemAsync<string>("darkMode");
                    
                if(dm!=null) {
                    if(dm=="true") {
                        baseLayerLuminance = 0;
                        darkMode = true;
                        modeIcon = FluentIcons.WeatherMoon;
                        await _localstorage.SetItemAsync<string>("darkMode", "true");
                            Console.WriteLine("OnParametersSetAsync darkmode: " + darkMode);
                    } else {
                        baseLayerLuminance = 100;
                        darkMode=false;
                        modeIcon = FluentIcons.WeatherSunny;
                        await _localstorage.SetItemAsync<string>("darkMode", "false");
                            Console.WriteLine("OnParametersSetAsync darkmode: " + darkMode);
                    }
                      
            }
        }


        private async Task changeColorMode() {
            if(baseLayerLuminance==100){
                baseLayerLuminance = 0;                
                Console.WriteLine("changeColorMode: DarkMode:" + darkMode + " | baseLayerLuminance: " + baseLayerLuminance);
                await _localstorage.SetItemAsync<string>("darkMode", "true");
                StateHasChanged();
            } else {
                baseLayerLuminance = 100;                
                Console.WriteLine("changeColorMode: DarkMode:" + darkMode + " | baseLayerLuminance: " + baseLayerLuminance);
                await _localstorage.SetItemAsync<string>("darkMode", "false");
                StateHasChanged();
            }
        }
    }

🤔 Expected Behavior

As no error is thrown, i would expect, that the icon is getting rendered.

😯 Current Behavior

VScode is saying that the name ConfigurationGenerator is not known.

image

But it compiles without errors:

image

The problem is, that the icon is not displayed. Not even present in the html output!

image

image>

💁 Possible Solution

🔦 Context

so, it would be nice if there is a way to get the icons working.

🌍 Your Environment

  • OS & Device: [Linux] on [iPC]
  • Browser [Google Chrome]
  • .NET 7.0
  • FAST 2.4.2

Issue Analytics

  • State:closed
  • Created a month ago
  • Reactions:1
  • Comments:14

github_iconTop GitHub Comments

2reactions
madcoda9000commented, Aug 19, 2023

PS: I forgot to mention, now it works with vscode like charm 😃

1reaction
vnbaaijcommented, Aug 19, 2023

I was about to post that… image ps. there is a PR waiting in your repo with upgrade done already…

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - How to fix C# Source Generators Issue of not found ...
CSC : warning CS8785: Generator 'OpenApiClientServicesGenerator' failed to generate source. It will not contribute to the output and compilation ...
Read more >
Source Generators Not Generating Sources #49249
I am having trouble getting the source generators to run/work. I am not sure what is not working. I have been working on...
Read more >
Scaffolding doesn't work when DbContext is in a separate ...
DbContext is registered in Program.cs as follows: builder.Services.AddDbContext<MyProjectDbContext>(options => options.UseSqlServer(builder.
Read more >
Source Generators
Source Generators is a C# compiler feature that lets C# developers inspect user code as it is being compiled. Source generators create new ......
Read more >
Configuration in ASP.NET Core
On Azure App Service, select New application setting on the Settings > Configuration page. Azure App Service application settings are:
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