Skip to content

Commit

Permalink
Allow duplicate compound type aliases (#8788)
Browse files Browse the repository at this point in the history
* fixes 8787

* Update CompoundTypeAliasTree.cs

---------

Co-authored-by: Ledjon Behluli <[email protected]>
Co-authored-by: Reuben Bond <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2023
1 parent 2bcd833 commit 94a83eb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Orleans.Serialization/TypeSystem/CompoundTypeAliasTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ private CompoundTypeAliasTree AddInternal(object key, Type? value)
{
if (value is not null && existing.Value is { } type && type != value)
{
throw new ArgumentException("A key with this value already exists");
// When the same grain interface is used across multiple assemblies which don't have cross references,
// code-gen will generate code for both because it works in isolation, yet at startup they are combined.

// In this case, if the key is present, and the value is the same as the one being added,
// and due to them being logically the same, we can just return the existing CompoundTypeAliasTree.

// The first one is allowed to win in this case.
return existing;
}

existing.Value = value;
Expand All @@ -104,4 +111,4 @@ private CompoundTypeAliasTree AddInternal(object key, Type? value)
return _children[key] = new CompoundTypeAliasTree(key, value);
}
}
}
}

0 comments on commit 94a83eb

Please sign in to comment.