Skip to content

Commit

Permalink
discard some lambda parameters (#4506)
Browse files Browse the repository at this point in the history
* discard some lambda parameters

* .

---------

Co-authored-by: Peter <[email protected]>
  • Loading branch information
SimonCropp and pmaytak authored Jan 19, 2024
1 parent 79aac69 commit c00920a
Show file tree
Hide file tree
Showing 39 changed files with 116 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal static void AddRuntimeSupportForWam(PublicClientApplicationBuilder buil
else
{
builder.Config.BrokerCreatorFunc =
(uiParent, appConfig, logger) =>
(_, _, logger) =>
{
logger.Info("[RuntimeBroker] Not a Windows 10 or Server equivalent machine. WAM is not available.");
return new NullBroker(logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public T WithDebugLoggingCallback(
bool withDefaultPlatformLoggingEnabled = false)
{
WithLogging(
(level, message, pii) => { Debug.WriteLine($"{level}: {message}"); },
(level, message, _) => { Debug.WriteLine($"{level}: {message}"); },
logLevel,
enablePiiLogging,
withDefaultPlatformLoggingEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public InstanceDiscoveryMetadataEntry GetMetadata(string environment, ILoggerAda
public void AddMetadata(string environment, InstanceDiscoveryMetadataEntry entry)
{
// Always take the most recent value
s_cache.AddOrUpdate(environment, entry, (key, oldValue) => entry);
s_cache.AddOrUpdate(environment, entry, (_, _) => entry);
}

public void Clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public StaTaskScheduler(int numberOfThreads)
_tasks = new BlockingCollection<Task>();

// Create the threads to be used by this scheduler
_threads = Enumerable.Range(0, numberOfThreads).Select(i =>
_threads = Enumerable.Range(0, numberOfThreads).Select(_ =>
{
var thread = new Thread(() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void WaitForCompletionOrTimeout(Thread uiThread)

// The invisible dialog has failed to complete in the allotted time.
// Attempt a graceful shutdown.
_formsSyncContext.Post(state => _dialog.CloseBrowser(), null);
_formsSyncContext.Post(_ => _dialog.CloseBrowser(), null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected override void WebBrowserBeforeNavigateHandler(object sender, WebBrowse
private static Timer CreateStartedTimer(Action onTickAction, int interval)
{
Timer timer = new Timer { Interval = interval };
timer.Tick += (notUsedsender, notUsedEventArgs) => onTickAction();
timer.Tick += (_, _) => onTickAction();
timer.Start();
return timer;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Microsoft.Identity.Test.Performance/BuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BuilderTests
{
private readonly X509Certificate2 _certificate;
private readonly IConfidentialClientApplication _cca;
private readonly LogCallback _logger = (message, level, isPii) => { };
private readonly LogCallback _logger = (_, _, _) => { };

public BuilderTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void TestConstructor_WithLogging()
var cca = ConfidentialClientApplicationBuilder
.Create(TestConstants.ClientId)
.WithClientSecret("cats")
.WithLogging((level, message, pii) => { }).Build();
.WithLogging((_, _, _) => { }).Build();

Assert.IsNotNull(cca.AppConfig.LoggingCallback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void TestConstructor_WithLogging()
{
var mi = ManagedIdentityApplicationBuilder
.Create(ManagedIdentityId.SystemAssigned)
.WithLogging((level, message, pii) => { })
.WithLogging((_, _, _) => { })
.BuildConcrete();

Assert.IsNotNull(mi.ServiceBundle.Config.LoggingCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void TestConstructor_WithDebugLoggingCallbackAndAppConfig()
};

var pca = PublicClientApplicationBuilder.CreateWithApplicationOptions(options)
.WithLogging((level, message, pii) => { }).Build();
.WithLogging((_, _, _) => { }).Build();

Assert.AreEqual(LogLevel.Error, pca.AppConfig.LogLevel);
Assert.IsTrue(pca.AppConfig.EnablePiiLogging);
Expand All @@ -144,7 +144,7 @@ public void TestConstructor_WithDebugLoggingCallbackAndAppConfigWithOverride()
};

var pca = PublicClientApplicationBuilder.CreateWithApplicationOptions(options)
.WithLogging((level, message, pii) => { },
.WithLogging((_, _, _) => { },
LogLevel.Verbose, true, false).Build();

Assert.AreEqual(LogLevel.Verbose, pca.AppConfig.LogLevel);
Expand Down Expand Up @@ -238,7 +238,7 @@ public void TestConstructor_WithHttpClientFactory()
public void TestConstructor_WithLogging()
{
var pca = PublicClientApplicationBuilder.Create(TestConstants.ClientId)
.WithLogging((level, message, pii) => { }, LogLevel.Verbose, true, true)
.WithLogging((_, _, _) => { }, LogLevel.Verbose, true, true)
.Build();

Assert.IsNotNull(pca.AppConfig.LoggingCallback);
Expand Down
6 changes: 3 additions & 3 deletions tests/Microsoft.Identity.Test.Unit/AppTokenProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task CheckRefreshInAsync(long expiresInResponse, long refreshInResp
{
string differentScopesForAt = string.Empty;
var app1 = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
.WithAppTokenProvider((AppTokenProviderParameters parameters) =>
.WithAppTokenProvider((AppTokenProviderParameters _) =>
{
AppTokenProviderResult result = new AppTokenProviderResult
{
Expand Down Expand Up @@ -168,7 +168,7 @@ public async Task ParallelRequests_CallTokenEndpointOnceAsync()

var app = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
.WithAuthority("https://login.microsoftonline.com/tid")
.WithAppTokenProvider((AppTokenProviderParameters parameters) =>
.WithAppTokenProvider((AppTokenProviderParameters _) =>
{
return Task.FromResult(GetAppTokenProviderResult());
})
Expand Down Expand Up @@ -210,7 +210,7 @@ public async Task CanceledRequest_ThrowsTaskCanceledExceptionAsync()
{
var app = ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
.WithInstanceDiscovery(false)
.WithAppTokenProvider((AppTokenProviderParameters parameters) =>
.WithAppTokenProvider((AppTokenProviderParameters _) =>
{
return Task.FromResult(GetAppTokenProviderResult());
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public async Task NullBrokerUsernamePasswordRequestTest_Async()
.Create(TestConstants.ClientId)
.WithHttpManager(harness.HttpManager);

builder.Config.BrokerCreatorFunc = (parent, config, logger) => { return new NullBroker(logger); };
builder.Config.BrokerCreatorFunc = (_, _, logger) => { return new NullBroker(logger); };

var app = builder.WithBroker(true).BuildConcrete();

Expand Down Expand Up @@ -460,7 +460,7 @@ public async Task NullAndIosBroker_GetAccounts_Async(Type brokerType)
.Create(TestConstants.ClientId)
.WithHttpManager(harness.HttpManager);

builder.Config.BrokerCreatorFunc = (parent, config, logger) => { return new NullBroker(logger); };
builder.Config.BrokerCreatorFunc = (_, _, logger) => { return new NullBroker(logger); };

var app = builder.WithBroker(true).BuildConcrete();

Expand All @@ -486,7 +486,7 @@ public async Task NullAndIosBroker_RemoveAccounts_Async(Type brokerType)
.Create(TestConstants.ClientId)
.WithHttpManager(harness.HttpManager);

builder.Config.BrokerCreatorFunc = (parent, config, logger) => { return broker; };
builder.Config.BrokerCreatorFunc = (_, _, _) => { return broker; };

var app = builder.WithBroker(true).BuildConcrete();

Expand All @@ -513,7 +513,7 @@ public async Task NullBroker_AcquireSilentInteractive_Async()
.Create(TestConstants.ClientId)
.WithHttpManager(harness.HttpManager);

builder.Config.BrokerCreatorFunc = (parent, config, logger) => { return new NullBroker(logger); };
builder.Config.BrokerCreatorFunc = (_, _, logger) => { return new NullBroker(logger); };

var app = builder.WithBroker(true).BuildConcrete();

Expand Down Expand Up @@ -559,7 +559,7 @@ public async Task iosBroker_AcquireSilentInteractive_Async()
.Create(TestConstants.ClientId)
.WithHttpManager(harness.HttpManager);

builder.Config.BrokerCreatorFunc = (parent, config, logger) => { return new IosBrokerMock(logger); };
builder.Config.BrokerCreatorFunc = (_, _, logger) => { return new IosBrokerMock(logger); };
builder.Config.PlatformProxy = platformProxy;

var app = builder.WithBroker(true).BuildConcrete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task WAM_AccountIdWriteback_Async()
.WithHttpManager(httpManager)
.BuildConcrete();

pca.ServiceBundle.Config.BrokerCreatorFunc = (x, y, z) => mockBroker;
pca.ServiceBundle.Config.BrokerCreatorFunc = (_, _, _) => mockBroker;

// Act
await pca.AcquireTokenInteractive(TestConstants.s_scope).ExecuteAsync().ConfigureAwait(false);
Expand All @@ -61,7 +61,7 @@ public async Task WAM_AccountIdWriteback_Async()
.WithHttpManager(httpManager)
.BuildConcrete();

pca2.ServiceBundle.Config.BrokerCreatorFunc = (app, config, logger) => mockBroker;
pca2.ServiceBundle.Config.BrokerCreatorFunc = (_, _, _) => mockBroker;

var accounts2 = await pca2.GetAccountsAsync().ConfigureAwait(false);
Assert.IsFalse(accounts2.Any());
Expand Down Expand Up @@ -101,8 +101,8 @@ public async Task WAM_AccountIds_GetMerged_Async()
cache.Bind(pca1.UserTokenCache);
cache.Bind(pca2.UserTokenCache);

pca1.ServiceBundle.Config.BrokerCreatorFunc = (app, config, logger) => mockBroker;
pca2.ServiceBundle.Config.BrokerCreatorFunc = (app, config, logger) => mockBroker;
pca1.ServiceBundle.Config.BrokerCreatorFunc = (_, _, _) => mockBroker;
pca2.ServiceBundle.Config.BrokerCreatorFunc = (_, _, _) => mockBroker;

// Act
mockBroker.AcquireTokenInteractiveAsync(null, null).ReturnsForAnyArgs(Task.FromResult(msalTokenResponse1));
Expand Down Expand Up @@ -190,7 +190,7 @@ public static class BrokerExt
{
internal static PublicClientApplicationBuilder WithTestBroker(this PublicClientApplicationBuilder pcaBuilder, IBroker mockBroker)
{
pcaBuilder.Config.BrokerCreatorFunc = (app, config, logger) => mockBroker;
pcaBuilder.Config.BrokerCreatorFunc = (_, _, _) => mockBroker;
pcaBuilder.Config.IsBrokerEnabled = true;

return pcaBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task Touch_FiresEvent_Async()
int cacheChangedEventFired = 0;

// expect this event to be fired twice
watcher.Changed += (sender, args) =>
watcher.Changed += (_, _) =>
{
_logger.TraceInformation("Event fired!");
cacheChangedEventFired++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ public async Task ClearCacheUsesTheLockAsync()
SemaphoreSlim semaphore2 = new SemaphoreSlim(0);
bool lockCreated = false, lockDeleted = false;

fileSystemWatcher.Created += (s, e) =>
fileSystemWatcher.Created += (_, _) =>
{
semaphore1.Release();
lockCreated = true;
};

fileSystemWatcher.Deleted += (s, e) =>
fileSystemWatcher.Deleted += (_, _) =>
{
semaphore2.Release();
lockDeleted = true;
Expand Down Expand Up @@ -445,7 +445,7 @@ public async Task EventFiresAsync()
int cacheChangedEventFired = 0;

// event is fired asynchronously, test has to wait for it for a while
helper.CacheChanged += (sender, e) =>
helper.CacheChanged += (_, _) =>
{
semaphore.Release();
cacheChangedEventFired++;
Expand Down Expand Up @@ -512,7 +512,7 @@ public async Task EventFires2Async()
int cacheChangedEventFired = 0;

// event is fired asynchronously, test has to wait for it for a while
helper.CacheChanged += (sender, e) =>
helper.CacheChanged += (_, _) =>
{
semaphore.Release();
cacheChangedEventFired++;
Expand Down Expand Up @@ -540,7 +540,7 @@ public async Task EventNeedsConfigurationAsync()

// event is fired asynchronously, test has to wait for it for a while
AssertException.Throws<InvalidOperationException>(
() => helper.CacheChanged += (sender, e) =>
() => helper.CacheChanged += (_, _) =>
{
Assert.Fail("Should not fire");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void CacheStorageCanHandleMultipleExceptionsWhenReading()
var cacheAccessor = Substitute.For<ICacheAccessor>();
var exception = new InvalidOperationException("some error");
cacheAccessor.Read().Throws(exception);
cacheAccessor.When((x) => x.Clear()).Do(x => throw exception);
cacheAccessor.When((x) => x.Clear()).Do(_ => throw exception);
_logger.Listeners.Add(stringListener);
var actualLogger = new TraceSourceLogger(_logger);
var storage = new Storage(s_storageCreationProperties, cacheAccessor, actualLogger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static Task WaitForExitAsync(this Process process,
{
var tcs = new TaskCompletionSource<object>();
process.EnableRaisingEvents = true;
process.Exited += (sender, args) =>
process.Exited += (_, _) =>
{
Trace.WriteLine($"Process finished {process.Id}");
tcs.TrySetResult(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ public void OptionsAndExternalCacheAreExclusive()
ConfidentialClientApplicationBuilder.Create(TestConstants.ClientId)
.WithClientSecret(TestConstants.ClientSecret)
.Build();
app3.UserTokenCache.SetAfterAccess((n) => { });
app3.AppTokenCache.SetBeforeAccess((n) => { });
app3.UserTokenCache.SetAfterAccess((_) => { });
app3.AppTokenCache.SetBeforeAccess((_) => { });
var ex = AssertException.Throws<MsalClientException>(() => app3.UserTokenCache.SetCacheOptions(CacheOptions.EnableSharedCacheOptions));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);
ex = AssertException.Throws<MsalClientException>(() => app3.AppTokenCache.SetCacheOptions(CacheOptions.EnableSharedCacheOptions));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);

void AssertExclusivity(ITokenCache tokenCache)
{
var ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetAfterAccess((n) => { }));
var ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetAfterAccess((_) => { }));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeAccess((n) => { }));
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeAccess((_) => { }));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeWrite((n) => { }));
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeWrite((_) => { }));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);

ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeAccessAsync((n) => Task.CompletedTask));
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeAccessAsync((_) => Task.CompletedTask));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetAfterAccessAsync((n) => Task.CompletedTask));
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetAfterAccessAsync((_) => Task.CompletedTask));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeWriteAsync((n) => Task.CompletedTask));
ex = AssertException.Throws<MsalClientException>(() => tokenCache.SetBeforeWriteAsync((_) => Task.CompletedTask));
Assert.AreEqual(MsalError.StaticCacheWithExternalSerialization, ex.ErrorCode);

}
Expand Down
Loading

0 comments on commit c00920a

Please sign in to comment.