Initial commit

This commit is contained in:
Jimmy Engström 2023-02-17 15:28:17 +01:00
parent 2190113c56
commit 3088165398
1765 changed files with 192085 additions and 0 deletions

View file

@ -0,0 +1,28 @@
using Microsoft.CodeAnalysis;
namespace SourceGenerator;
[Generator]
public class HelloSourceGenerator : ISourceGenerator
{
public void Execute(GeneratorExecutionContext context)
{
// Build up the source code
string source = """
namespace BlazorWebAssemblyApp;
public class GeneratedService
{
public string GetHello()
{
return "Hello from generated code";
}
}
""";
// Add the source code to the compilation
context.AddSource($"GeneratedService.g.cs", source);
}
public void Initialize(GeneratorInitializationContext context)
{
// No initialization required for this one
}
}

View file

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>