@@ -10,11 +10,11 @@ namespace ReferenceReplacement.Logic;
1010
1111internal static class ReferenceScanner
1212{
13- public static ReferenceScanResult Scan ( Slot root , IWorldElement source , IWorldElement target )
13+ public static ReferenceScanResult Scan ( Slot root , IWorldElement source , IWorldElement target , Slot ? excludedSlot = null )
1414 {
1515 ArgumentNullException . ThrowIfNull ( root ) ;
1616
17- ReferenceScanSession session = new ( source , target ) ;
17+ ReferenceScanSession session = new ( source , target , excludedSlot ) ;
1818 session . VisitSlot ( root , TraversalPath . FromSlot ( root ) ) ;
1919 return session . BuildResult ( ) ;
2020 }
@@ -23,7 +23,7 @@ internal static ReferenceScanResult Scan(HierarchyBlueprint blueprintRoot, IWorl
2323 {
2424 ArgumentNullException . ThrowIfNull ( blueprintRoot ) ;
2525
26- ReferenceScanSession session = new ( source , target ) ;
26+ ReferenceScanSession session = new ( source , target , excludedSlot : null ) ;
2727 session . VisitBlueprint ( blueprintRoot , new ( blueprintRoot . Label ) ) ;
2828 return session . BuildResult ( ) ;
2929 }
@@ -32,6 +32,7 @@ private sealed class ReferenceScanSession
3232 {
3333 private readonly IWorldElement _source ;
3434 private readonly IWorldElement _target ;
35+ private readonly Slot ? _excludedSlot ;
3536 private readonly List < SyncReferenceMatch > _matches = new ( ) ;
3637 private readonly HashSet < ISyncRef > _visitedRefs = new ( ) ;
3738 private readonly HashSet < object > _visitedEnumerables = new ( ReferenceEqualityComparer . Instance ) ;
@@ -40,15 +41,16 @@ private sealed class ReferenceScanSession
4041 private int _incompatibleCount ;
4142 private string ? _lastPath ;
4243
43- internal ReferenceScanSession ( IWorldElement source , IWorldElement target )
44+ internal ReferenceScanSession ( IWorldElement source , IWorldElement target , Slot ? excludedSlot )
4445 {
4546 _source = source ?? throw new ArgumentNullException ( nameof ( source ) ) ;
4647 _target = target ?? throw new ArgumentNullException ( nameof ( target ) ) ;
48+ _excludedSlot = excludedSlot ;
4749 }
4850
4951 internal void VisitSlot ( Slot ? slot , TraversalPath path )
5052 {
51- if ( slot == null )
53+ if ( slot == null || ReferenceEquals ( slot , _excludedSlot ) )
5254 {
5355 return ;
5456 }
@@ -387,4 +389,4 @@ internal sealed class ReferenceEqualityComparer : IEqualityComparer<object>
387389 public new bool Equals ( object ? x , object ? y ) => ReferenceEquals ( x , y ) ;
388390
389391 public int GetHashCode ( object obj ) => RuntimeHelpers . GetHashCode ( obj ) ;
390- }
392+ }
0 commit comments