Skip to content

Commit 18a8cbe

Browse files
committed
fix: removes loop methods from parsing context as its available in loop detector instead
1 parent a0d1845 commit 18a8cbe

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

src/Microsoft.OpenApi/Reader/ParsingContext.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class ParsingContext
1919
private readonly Stack<string> _currentLocation = new();
2020
private readonly Dictionary<string, object> _tempStorage = new();
2121
private readonly Dictionary<object, Dictionary<string, object>> _scopedTempStorage = new();
22-
private readonly Dictionary<string, Stack<string>> _loopStacks = new();
2322

2423
/// <summary>
2524
/// Extension parsers
@@ -219,53 +218,6 @@ public void StartObject(string objectName)
219218
{
220219
_currentLocation.Push(objectName);
221220
}
222-
223-
/// <summary>
224-
/// Maintain history of traversals to avoid stack overflows from cycles
225-
/// </summary>
226-
/// <param name="loopId">Any unique identifier for a stack.</param>
227-
/// <param name="key">Identifier used for current context.</param>
228-
/// <returns>If method returns false a loop was detected and the key is not added.</returns>
229-
public bool PushLoop(string loopId, string key)
230-
{
231-
if (!_loopStacks.TryGetValue(loopId, out var stack))
232-
{
233-
stack = new();
234-
_loopStacks.Add(loopId, stack);
235-
}
236-
237-
if (!stack.Contains(key))
238-
{
239-
stack.Push(key);
240-
return true;
241-
}
242-
else
243-
{
244-
return false; // Loop detected
245-
}
246-
}
247-
248-
/// <summary>
249-
/// Reset loop tracking stack
250-
/// </summary>
251-
/// <param name="loopid">Identifier of loop to clear</param>
252-
internal void ClearLoop(string loopid)
253-
{
254-
_loopStacks[loopid].Clear();
255-
}
256-
257-
/// <summary>
258-
/// Exit from the context in cycle detection
259-
/// </summary>
260-
/// <param name="loopid">Identifier of loop</param>
261-
public void PopLoop(string loopid)
262-
{
263-
if (_loopStacks[loopid].Count > 0)
264-
{
265-
_loopStacks[loopid].Pop();
266-
}
267-
}
268-
269221
private void ValidateRequiredFields(OpenApiDocument doc, string version)
270222
{
271223
if ((version.is2_0() || version.is3_0()) && (doc.Paths == null) && RootNode is not null)

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,8 +2012,6 @@ namespace Microsoft.OpenApi.Reader
20122012
public Microsoft.OpenApi.OpenApiDocument Parse(System.Text.Json.Nodes.JsonNode jsonNode, System.Uri ___location) { }
20132013
public T? ParseFragment<T>(System.Text.Json.Nodes.JsonNode jsonNode, Microsoft.OpenApi.OpenApiSpecVersion version, Microsoft.OpenApi.OpenApiDocument openApiDocument)
20142014
where T : Microsoft.OpenApi.IOpenApiElement { }
2015-
public void PopLoop(string loopid) { }
2016-
public bool PushLoop(string loopId, string key) { }
20172015
public void SetTempStorage(string key, object? value, object? scope = null) { }
20182016
public void StartObject(string objectName) { }
20192017
}

0 commit comments

Comments
 (0)