Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dpg): same type property only mock once #3633

Merged
merged 5 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,35 @@ var data = new {
description = "<description>",
disabled = true,
disableRecursiveReplacerApplication = true,
doNotReplaceRegex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
lastUpdatedTimestamp = 1234L,
modifiedBy = "<modifiedBy>",
name = "<name>",
regex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
replaceWith = "<replaceWith>",
}
},
Expand Down Expand Up @@ -499,9 +525,35 @@ var data = new {
description = "<description>",
disabled = true,
disableRecursiveReplacerApplication = true,
doNotReplaceRegex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
lastUpdatedTimestamp = 1234L,
modifiedBy = "<modifiedBy>",
name = "<name>",
regex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
replaceWith = "<replaceWith>",
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,35 @@ public void Example_CreateOrUpdateResourceSetRule_AllParameters()
description = "<description>",
disabled = true,
disableRecursiveReplacerApplication = true,
doNotReplaceRegex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
lastUpdatedTimestamp = 1234L,
modifiedBy = "<modifiedBy>",
name = "<name>",
regex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
replaceWith = "<replaceWith>",
}
},
Expand Down Expand Up @@ -554,9 +580,35 @@ public async Task Example_CreateOrUpdateResourceSetRule_AllParameters_Async()
description = "<description>",
disabled = true,
disableRecursiveReplacerApplication = true,
doNotReplaceRegex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
lastUpdatedTimestamp = 1234L,
modifiedBy = "<modifiedBy>",
name = "<name>",
regex = new {
maxDigits = 1234,
maxLetters = 1234,
minDashes = 1234,
minDigits = 1234,
minDigitsOrLetters = 1234,
minDots = 1234,
minHex = 1234,
minLetters = 1234,
minUnderscores = 1234,
options = 1234,
regexStr = "<regexStr>",
},
replaceWith = "<replaceWith>",
}
},
Expand Down
31 changes: 31 additions & 0 deletions src/AutoRest.CSharp/Common/Utilities/HashSetExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoRest.CSharp.Utilities;

namespace AutoRest.CSharp.Common.Utilities
{
internal static class HashSetExtensions
{
/// <summary>
/// Push an item into the set, which will be popped later when the returned <see cref="IDisposable"/> is disposed.
/// </summary>
/// <typeparam name="T"><see cref="HashSet{T}">HashSet</see> item</typeparam>
/// <param name="hashSet"></param>
/// <param name="item">Item to push</param>
/// <returns></returns>
internal static IDisposable Push<T>(this HashSet<T> hashSet, T item)
{
hashSet.Add(item);
return Disposable.Create(() =>
{
hashSet.Remove(item);
});
}
}
}
Loading