Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
getsentry-bot committed Aug 26, 2024
1 parent 2b5cd57 commit 49029e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
54 changes: 27 additions & 27 deletions src/Sentry/StringOrRegex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,33 @@ public static bool MatchesAny(this string parameter, IEnumerable<StringOrRegex>?
public static bool MatchesSubstringOrRegex(this IEnumerable<StringOrRegex>? patterns, string parameter)
=> parameter.MatchesAny(patterns, SubstringOrPatternMatcher.Default);

/// <summary>
/// During configuration binding, .NET 6 and lower used to just call Add on the existing item.
/// .NET 7 changed this to call the setter with an array that already starts with the old value.
/// We have to handle both cases.
/// </summary>
/// <typeparam name="T">The List Type</typeparam>
/// <param name="value">The set of values to be assigned</param>
/// <returns>A IList of type T that will be consistent even if it has been set via Config</returns>
public static IList<T> WithConfigBinding<T>(this IList<T> value)
where T : StringOrRegex
{
switch (value.Count)
{
case 1 when value[0].ToString() == ".*":
// There's only one item in the list, and it's the wildcard, so reset to the initial state.
return new AutoClearingList<T>(value, clearOnNextAdd: true);

case > 1:
// There's more than one item in the list. Remove the wildcard.
var targets = value.ToList();
targets.RemoveAll(t => t.ToString() == ".*");
return targets;

default:
return value;
}
}
/// <summary>
/// During configuration binding, .NET 6 and lower used to just call Add on the existing item.
/// .NET 7 changed this to call the setter with an array that already starts with the old value.
/// We have to handle both cases.
/// </summary>
/// <typeparam name="T">The List Type</typeparam>
/// <param name="value">The set of values to be assigned</param>
/// <returns>A IList of type T that will be consistent even if it has been set via Config</returns>
public static IList<T> WithConfigBinding<T>(this IList<T> value)
where T : StringOrRegex
{
switch (value.Count)
{
case 1 when value[0].ToString() == ".*":
// There's only one item in the list, and it's the wildcard, so reset to the initial state.
return new AutoClearingList<T>(value, clearOnNextAdd: true);

case > 1:
// There's more than one item in the list. Remove the wildcard.
var targets = value.ToList();
targets.RemoveAll(t => t.ToString() == ".*");
return targets;

default:
return value;
}
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Configure_BindsConfigurationToOptions()
CacheDirectoryPath = "~/test",
CaptureFailedRequests = true,
// FailedRequestStatusCodes = IList<HttpStatusCodeRange>,
FailedRequestTargets = [ "target1", "target2" ],
FailedRequestTargets = ["target1", "target2"],
InitCacheFlushTimeout = TimeSpan.FromSeconds(27),
// DefaultTags = Dictionary<string,string>,
#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
4 changes: 2 additions & 2 deletions test/Sentry.Tests/SubstringOrPatternMatcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class SubstringOrPatternMatcherTests
{
private static class Fixture
{
public static SubstringOrPatternMatcher GetSut() => new ();
public static SubstringOrPatternMatcher GetSut(StringComparison comparison) => new (comparison);
public static SubstringOrPatternMatcher GetSut() => new();
public static SubstringOrPatternMatcher GetSut(StringComparison comparison) => new(comparison);
}

[Theory]
Expand Down

0 comments on commit 49029e6

Please sign in to comment.