Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
63fd7d5
Add incremental source generator work
ReubenBond Apr 23, 2026
6488e13
Simplify incremental generator model equality
ReubenBond Apr 24, 2026
6458339
Improve source generator build performance
ReubenBond Apr 24, 2026
54d8bea
Optimize incremental source generator performance
ReubenBond Apr 28, 2026
9c51a13
Use metadata identities for resolver
ReubenBond Apr 28, 2026
f1efb2a
Fix transaction request serialization
ReubenBond Apr 28, 2026
a66a632
Remove legacy code generator facade
ReubenBond Apr 28, 2026
aaac1df
Emit generated metadata last
ReubenBond Apr 28, 2026
abe8c3a
Minimize metadata ordering snapshot churn
ReubenBond Apr 28, 2026
3388fa7
Remove source generator snapshot churn
ReubenBond Apr 28, 2026
7c5c98c
Reduce code generator model churn
ReubenBond Apr 28, 2026
3d742c7
Rename compound alias emission helper
ReubenBond Apr 28, 2026
c86f9fa
Restore generated invokable activator metadata
ReubenBond Apr 28, 2026
2901205
Close incremental generator parity gaps
ReubenBond Apr 28, 2026
3e5fc6c
Fix net10 referenced diagnostics
ReubenBond Apr 28, 2026
639aa79
Address code generator review feedback
ReubenBond Apr 28, 2026
57ad67f
Handle record primary constructor field ids
ReubenBond Apr 28, 2026
1c8bd07
Add incremental source generator regression tests
ReubenBond Apr 29, 2026
844897d
Preserve record field id wire format
ReubenBond Apr 29, 2026
3577f57
cleanup
ReubenBond Apr 29, 2026
304af04
Use structural equality wrapper for CodeGenerator models
ReubenBond Apr 29, 2026
2838cb7
Split CodeGenerator helpers into named classes
ReubenBond Apr 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<ProjectReference
Include="$(SourceRoot)src/Orleans.CodeGenerator/Orleans.CodeGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
PrivateAssets="None"
Condition=" '$(OrleansBuildTimeCodeGen)' == 'true' "/>
<ProjectReference
Expand All @@ -22,6 +23,7 @@
UndefineProperties="TargetFramework"
SkipGetTargetFrameworkProperties="true"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
PrivateAssets="None"
Condition=" '$(OrleansBuildTimeCodeGen)' == 'true' "/>
</ItemGroup>
Expand Down
30 changes: 23 additions & 7 deletions src/Orleans.CodeGenerator/ActivatorGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Orleans.CodeGenerator
{
internal class ActivatorGenerator
{
private readonly CodeGenerator _codeGenerator;
private readonly IGeneratorServices _generatorServices;

private struct ConstructorArgument
{
Expand All @@ -17,16 +17,16 @@ private struct ConstructorArgument
public string ParameterName { get; set; }
}

public ActivatorGenerator(CodeGenerator codeGenerator)
public ActivatorGenerator(IGeneratorServices generatorServices)
{
_codeGenerator = codeGenerator;
_generatorServices = generatorServices;
}

public ClassDeclarationSyntax GenerateActivator(ISerializableTypeDescription type)
{
var simpleClassName = GetSimpleClassName(type);

var baseInterface = _codeGenerator.LibraryTypes.IActivator_1.ToTypeSyntax(type.TypeSyntax);
var baseInterface = _generatorServices.LibraryTypes.IActivator_1.ToTypeSyntax(type.TypeSyntax);

var orderedFields = new List<ConstructorArgument>();
var index = 0;
Expand Down Expand Up @@ -57,7 +57,7 @@ public ClassDeclarationSyntax GenerateActivator(ISerializableTypeDescription typ
var classDeclaration = ClassDeclaration(simpleClassName)
.AddBaseListTypes(SimpleBaseType(baseInterface))
.AddModifiers(Token(SyntaxKind.InternalKeyword), Token(SyntaxKind.SealedKeyword))
.AddAttributeLists(CodeGenerator.GetGeneratedCodeAttributes())
.AddAttributeLists(GeneratedCodeUtilities.GetGeneratedCodeAttributes())
.AddMembers(members.ToArray());

if (type.IsGenericType)
Expand All @@ -68,7 +68,23 @@ public ClassDeclarationSyntax GenerateActivator(ISerializableTypeDescription typ
return classDeclaration;
}

public static string GetSimpleClassName(ISerializableTypeDescription serializableType) => $"Activator_{serializableType.Name}";
public static string GetSimpleClassName(ISerializableTypeDescription serializableType) => GetSimpleClassName(serializableType.Name);

public static string GetSimpleClassName(string name) => $"Activator_{name}";

/// <summary>
/// Determines whether an activator should be generated for the specified type.
/// </summary>
internal static bool ShouldGenerateActivator(ISerializableTypeDescription type)
{
return !type.IsAbstractType
&& !type.IsEnumType
&& (!type.IsValueType
&& type.IsEmptyConstructable
&& !type.UseActivator
&& type is not GeneratedInvokableDescription
|| type.HasActivatorConstructor);
}

private ConstructorDeclarationSyntax GenerateConstructor(
string simpleClassName,
Expand Down Expand Up @@ -126,4 +142,4 @@ private MemberDeclarationSyntax GenerateCreateMethod(ISerializableTypeDescriptio
.AddModifiers(Token(SyntaxKind.PublicKeyword));
}
}
}
}
10 changes: 5 additions & 5 deletions src/Orleans.CodeGenerator/ApplicationPartAttributeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
using System.Collections.Generic;
using Orleans.CodeGenerator.SyntaxGeneration;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Orleans.CodeGenerator.SyntaxGeneration;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;

namespace Orleans.CodeGenerator
{
internal static class ApplicationPartAttributeGenerator
internal static class ApplicationPartAttributeGenerator
{
public static List<AttributeListSyntax> GenerateSyntax(LibraryTypes wellKnownTypes, MetadataModel model)
public static List<AttributeListSyntax> GenerateSyntax(NameSyntax applicationPartAttribute, IEnumerable<string> applicationParts)
{
var attributes = new List<AttributeListSyntax>();

foreach (var assemblyName in model.ApplicationParts)
foreach (var assemblyName in applicationParts)
{
// Generate an assembly-level attribute with an instance of that class.
var attribute = AttributeList(
AttributeTargetSpecifier(Token(SyntaxKind.AssemblyKeyword)),
SingletonSeparatedList(
Attribute(wellKnownTypes.ApplicationPartAttribute.ToNameSyntax())
Attribute(applicationPartAttribute)
.AddArgumentListArguments(AttributeArgument(assemblyName.GetLiteralExpression()))));
attributes.Add(attribute);
}
Expand Down
Loading
Loading