-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6abd883
commit 7c11520
Showing
8 changed files
with
74 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 21 additions & 1 deletion
22
src/FluentWorkflow.Generator/Model/CompilationProperties.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
namespace FluentWorkflow.Generator.Model; | ||
|
||
internal record struct CompilationProperties(string RootNameSpace, HashSet<GeneratorAdditional> GeneratorAdditionals); | ||
internal record struct CompilationProperties(string RootNameSpace, IReadOnlyList<GeneratorAdditional> GeneratorAdditionals) | ||
: IEquatable<CompilationProperties> | ||
{ | ||
private readonly IReadOnlyList<GeneratorAdditional> _orderedGeneratorAdditionals = GeneratorAdditionals.OrderBy(static m => (int)m).ToList(); | ||
|
||
public override readonly int GetHashCode() | ||
{ | ||
var hashCode = RootNameSpace.GetHashCode(); | ||
foreach (var generatorAdditional in _orderedGeneratorAdditionals) | ||
{ | ||
hashCode &= generatorAdditional.GetHashCode(); | ||
} | ||
return hashCode; | ||
} | ||
|
||
public readonly bool Equals(CompilationProperties other) | ||
{ | ||
return RootNameSpace.Equals(other.RootNameSpace) | ||
&& Enumerable.SequenceEqual(_orderedGeneratorAdditionals, other._orderedGeneratorAdditionals); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,38 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
namespace FluentWorkflow.Generator.Model; | ||
|
||
record struct WorkflowDescriptor(ClassDeclarationSyntax DeclarationSyntax, | ||
INamedTypeSymbol TypeSymbol, | ||
string Name, | ||
string NameSpace); | ||
internal record struct WorkflowDescriptor(ClassDeclarationSyntax DeclarationSyntax, string Name, string NameSpace) | ||
: IEquatable<WorkflowDescriptor> | ||
{ | ||
/// <inheritdoc/> | ||
public override readonly int GetHashCode() | ||
{ | ||
//认为名称和命名空间相同则相同? | ||
return Name.GetHashCode() & NameSpace.GetHashCode(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public readonly bool Equals(WorkflowDescriptor other) | ||
{ | ||
return string.Equals(Name, other.Name, StringComparison.Ordinal) | ||
&& string.Equals(NameSpace, other.NameSpace, StringComparison.Ordinal); | ||
} | ||
} | ||
|
||
internal sealed class WorkflowDescriptorEqualityComparer : IEqualityComparer<WorkflowDescriptor> | ||
{ | ||
#region Public 属性 | ||
|
||
public static WorkflowDescriptorEqualityComparer Shared { get; } = new(); | ||
|
||
#endregion Public 属性 | ||
|
||
#region Public 方法 | ||
|
||
public bool Equals(WorkflowDescriptor x, WorkflowDescriptor y) => x.Equals(y); | ||
|
||
public int GetHashCode(WorkflowDescriptor obj) => obj.GetHashCode(); | ||
|
||
#endregion Public 方法 | ||
} |