AnnaSasDev
AnnaSasDev
CC#
Created by AnnaSasDev on 3/20/2025 in #help
Extending a razor component so I can make developer experience a bit easier
Have eventually "figured out" a solution that I wanted, though Im still debating the fact if this is the best approach in the long run. Made a small manual cli tool, instead of a Roslyn Incremental Generator, that parses the svg files from lucide-static into individual razor files, which follow the naming convention of Li{lucideName.ToPascalCase()} (pseudo). Ive also made the option to resolve the icon the old way, through a simple inject ILucideService so you can now have two options. This service works by using an underlying dictionary with lazy loaded values, which is populated by a Roslyn Incremental Generator meaning hat I can use an Icon in two ways:
<LucideIcon name="signature">
or
<LiSignature/>
<LucideIcon name="signature">
or
<LiSignature/>
For anyone wondering, the full package's code is here: (constructive feedback is always appreciated): https://github.com/InfiniLore/lucide.blazor
4 replies
CC#
Created by AnnaSasDev on 3/20/2025 in #help
Extending a razor component so I can make developer experience a bit easier
But the only way Ive been able to make this work is by doing the following (work in progress testing):
public partial class LucideIcon {
public static RenderFragment Render(string iconSvgContent, Dictionary<string, object>? attributes = null)
=> builder => {
builder.OpenComponent<LucideIcon>(0); // Parent LucideIcon component
builder.AddAttribute(1, "SvgContent", new MarkupString(iconSvgContent));
builder.AddMultipleAttributes(2, attributes ?? new Dictionary<string, object>()); // Dynamically apply attributes
builder.CloseComponent();
};

// Predefined Signature RenderFragment with customizable attributes
public static RenderFragment Signature(string @class = "") =>
Render(Data.Signature._flatSvgContent, new Dictionary<string, object>() {
["class"] = @class,
});
}
public partial class LucideIcon {
public static RenderFragment Render(string iconSvgContent, Dictionary<string, object>? attributes = null)
=> builder => {
builder.OpenComponent<LucideIcon>(0); // Parent LucideIcon component
builder.AddAttribute(1, "SvgContent", new MarkupString(iconSvgContent));
builder.AddMultipleAttributes(2, attributes ?? new Dictionary<string, object>()); // Dynamically apply attributes
builder.CloseComponent();
};

// Predefined Signature RenderFragment with customizable attributes
public static RenderFragment Signature(string @class = "") =>
Render(Data.Signature._flatSvgContent, new Dictionary<string, object>() {
["class"] = @class,
});
}
which then results in the following workaround.
@LucideIcon.Signature(@class:"validation-message")
@LucideIcon.Signature(@class:"validation-message")
Because razor files are already brought dozn to C# through a roslyn generator, Im unsure if I could build something like I envisioned with the <LucideIcon.Signature/> idea
4 replies
CC#
Created by AnnaSasDev on 3/1/2025 in #help
Issue with Github Actions when using Node & Dotnet together
Issue is resolved The issue could be traced back to IncrementalGeneratorInitializationContextExtensions.SelectLucideSvgFiles where we were checking if a filepath matches a regex (why of all reasons I did this, ill never remember) and the age old / vs \ paths caused the issue. Changed it to a simpler FileEndsWith() and thus the issue is resolved
2 replies
CC#
Created by AnnaSasDev on 2/20/2025 in #help
Issue with configuring Auth0 and the "Allowed Callback url"
from as far as I can understand their docs, I think the callback is the OIDC redirect_uri , which I can't override myself as far as I understand I eventually got a beginning to the functionality that I wanted by using the OnAuthenticationStateChangedfrom PersistingRevalidatingAuthenticationStateProvider https://github.com/InfiniLore/infinilore.cs/blob/6acef6a31869d16fbb9063c3ac3a0a6d15f96847/src/InfiniLore.Server.Services/AuthenticationStateSyncer/PersistingRevalidatingAuthenticationStateProvider.cs#L63 Which I can then at a later point use to create a command which creates a user for my database I just feel frustrated because this feels like such a convoluted workaround to get to the functionality that I want
13 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
right, I've learned something new today then ... Thanks so much!
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
... what the .. yeah that fixed it?!? I'm so confused why this works ... but okay
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
<!-- Ensure important files are packaged correctly -->
<ItemGroup Condition="'$(Configuration)' != 'Benchmark'">
<None Include="$(SolutionDir)LICENSE" Pack="true" PackagePath="" Visible="false" />
<None Include="$(SolutionDir)README.md" Pack="true" PackagePath="" Visible="false" />
<None Include="$(SolutionDir)assets/icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<!-- Reference dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
</ItemGroup>

</Project>
<!-- Ensure important files are packaged correctly -->
<ItemGroup Condition="'$(Configuration)' != 'Benchmark'">
<None Include="$(SolutionDir)LICENSE" Pack="true" PackagePath="" Visible="false" />
<None Include="$(SolutionDir)README.md" Pack="true" PackagePath="" Visible="false" />
<None Include="$(SolutionDir)assets/icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<!-- Reference dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
</ItemGroup>

</Project>
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
csproj file of CodeOfChaos.GeneratorTools :
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<DevelopmentDependency>true</DevelopmentDependency>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>

<!-- Main package metadata -->
<PackageId>CodeOfChaos.GeneratorTools</PackageId>
<Version>1.1.0</Version>
<Authors>Anna Sas</Authors>
<Description>A library to help you create code generators more easily</Description>
<PackageProjectUrl>https://github.com/code-of-chaos/cs-code_of_chaos-generator_tools/</PackageProjectUrl>
<PackageTags>roslyn code-generator generator source-generator source</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<PackageLicenseFile Condition="'$(Configuration)' != 'Benchmark'">LICENSE</PackageLicenseFile>
<PackageReadmeFile Condition="'$(Configuration)' != 'Benchmark'">README.md</PackageReadmeFile>
<PackageIcon Condition="'$(Configuration)' != 'Benchmark'">icon.png</PackageIcon>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<DevelopmentDependency>true</DevelopmentDependency>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>

<!-- Main package metadata -->
<PackageId>CodeOfChaos.GeneratorTools</PackageId>
<Version>1.1.0</Version>
<Authors>Anna Sas</Authors>
<Description>A library to help you create code generators more easily</Description>
<PackageProjectUrl>https://github.com/code-of-chaos/cs-code_of_chaos-generator_tools/</PackageProjectUrl>
<PackageTags>roslyn code-generator generator source-generator source</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<PackageLicenseFile Condition="'$(Configuration)' != 'Benchmark'">LICENSE</PackageLicenseFile>
<PackageReadmeFile Condition="'$(Configuration)' != 'Benchmark'">README.md</PackageReadmeFile>
<PackageIcon Condition="'$(Configuration)' != 'Benchmark'">icon.png</PackageIcon>
</PropertyGroup>
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
<!-- Include external files -->
<ItemGroup>
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false" />
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false" />
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<!-- Package dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="CodeOfChaos.GeneratorTools" Version="1.1.0" Pack="true" GeneratePathProperty="true" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgCodeOfChaos_GeneratorTools)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

</Project>
<!-- Include external files -->
<ItemGroup>
<None Include="../../LICENSE" Pack="true" PackagePath="" Visible="false" />
<None Include="../../README.md" Pack="true" PackagePath="" Visible="false" />
<None Include="../../assets/icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<!-- Package dependencies -->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" PrivateAssets="all" />
<PackageReference Include="CodeOfChaos.GeneratorTools" Version="1.1.0" Pack="true" GeneratePathProperty="true" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="$(PkgCodeOfChaos_GeneratorTools)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

</Project>
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
csproj file of AterraEngine.Unions.Generators : (had to split the file because of max message length)
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build -->
<IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency -->
<IsDeveloperDependency>true</IsDeveloperDependency>
<DevelopmentDependency>true</DevelopmentDependency>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<NoWarn>NU5128</NoWarn>

<!-- Package metadata -->
<PackageId>AterraEngine.Unions.Generators</PackageId>
<Version>3.5.0</Version>
<Authors>Anna Sas</Authors>
<Description>The Source Generator for AterraEngine.Unions</Description>
<PackageProjectUrl>https://github.com/AterraEngine/unions-cs/</PackageProjectUrl>
<PackageTags>discriminated unions;rosyln;generator</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>true</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>

<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build -->
<IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency -->
<IsDeveloperDependency>true</IsDeveloperDependency>
<DevelopmentDependency>true</DevelopmentDependency>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<NoWarn>NU5128</NoWarn>

<!-- Package metadata -->
<PackageId>AterraEngine.Unions.Generators</PackageId>
<Version>3.5.0</Version>
<Authors>Anna Sas</Authors>
<Description>The Source Generator for AterraEngine.Unions</Description>
<PackageProjectUrl>https://github.com/AterraEngine/unions-cs/</PackageProjectUrl>
<PackageTags>discriminated unions;rosyln;generator</PackageTags>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<DebugType>embedded</DebugType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>
8 replies
CC#
Created by AnnaSasDev on 1/9/2025 in #help
Roslyn not finding a referenced package
I haven't created a new latest nuget package for AterraEngine.Unions.Generators yet as the code isn't working. Within the project there is a Sample project AterraEngine.Unions.Generators.Sample which when I try and build outputs:
1>CSC: Warning CS8785 : Generator 'UnionGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'FileNotFoundException' with message 'Could not load file or assembly 'CodeOfChaos.GeneratorTools, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'.
1>CSC: Warning CS8785 : Generator 'UnionGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'FileNotFoundException' with message 'Could not load file or assembly 'CodeOfChaos.GeneratorTools, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'.
AterraEngine.Unions.Generators is on the latest uploaded version of CodeOfChaos.GeneratorTools which is 1.1.0
8 replies