Skip to content

Commit

Permalink
Merge pull request #93 from chickensoft-games/fix/generic-transitions
Browse files Browse the repository at this point in the history
fix: generic logic block transitions
  • Loading branch information
jolexxa authored Oct 9, 2024
2 parents c7a289d + 3fc6d2e commit 8cbbe5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@startuml GenericLogicBlock
state "GenericLogicBlock State" as Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType___GenericLogicBlock_State {
state "GenericLogicBlock State" as Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_State {
state "StateOne" as Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateOne
state "StateTwo" as Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateTwo
}

Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateOne --> Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateTwo : InputOne
Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateTwo --> Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_StateOne : InputTwo
[*] --> Chickensoft_LogicBlocks_DiagramGenerator_Tests_TestCases_MyGenericType_GenericLogicBlock_State
@enduml
4 changes: 3 additions & 1 deletion Chickensoft.LogicBlocks.DiagramGenerator/src/Diagrammer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ CancellationToken token

// Base state becomes the root
var root = new LogicBlockGraph(
id: CodeService.GetNameFullyQualified(concreteState, concreteState.Name),
id: CodeService.GetNameFullyQualifiedWithoutGenerics(
concreteState, concreteState.Name
),
name: concreteState.Name,
baseId: CodeService.GetNameFullyQualifiedWithoutGenerics(
concreteState, concreteState.Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ namespace Chickensoft.SourceGeneratorUtils;

public static class SymbolExtensions {
public static bool InheritsFromOrEquals(
this ITypeSymbol type, ITypeSymbol baseType) =>
this ITypeSymbol type, INamedTypeSymbol baseType) =>
type
.GetBaseTypesAndThis()
.Any(t => SymbolEqualityComparer.Default.Equals(t, baseType));
.Any(t => SymbolEqualityComparer.Default.Equals(t, baseType)) ||
(
baseType.IsGenericType &&
type.GetBaseTypesAndThis().Any(t =>
SymbolEqualityComparer.Default.Equals(
t.OriginalDefinition,
baseType.OriginalDefinition
)
)
);

private static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(
this ITypeSymbol? type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ReturnTypeVisitor : CSharpSyntaxWalker {
public INamedTypeSymbol StateType { get; }
private readonly HashSet<string> _returnTypes = new();

public ImmutableHashSet<string> ReturnTypes => _returnTypes.ToImmutableHashSet();
public ImmutableHashSet<string> ReturnTypes => [.. _returnTypes];

public ReturnTypeVisitor(
SemanticModel model,
Expand Down

0 comments on commit 8cbbe5f

Please sign in to comment.