Skip to content

Commit

Permalink
[Infrastructure] Unblock installer (#55358)
Browse files Browse the repository at this point in the history
* Fixes to analyzers and build infrastructure.
  • Loading branch information
javiercn authored Apr 25, 2024
1 parent 120b944 commit 8951d73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
9 changes: 7 additions & 2 deletions eng/tools/RepoTasks/RemoveSharedFrameworkDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ private void FilterDependencies(string targetPath, ISet<string> dependencyToRemo
var updatedGroup = new PackageDependencyGroup(group.TargetFramework, packages);
foreach (var dependency in group.Packages)
{
if (dependencyToRemove.Contains(dependency.Id))
// Hack to temporarily avoid using ISet.Contains
if (!dependencyToRemove.Add(dependency.Id))
{
referencesFrameworkOnlyAssembly = true;
Log.LogMessage($" Remove dependency on '{dependency.Id}'");
continue;
}
else
{
dependencyToRemove.Remove(dependency.Id);
}

packages.Add(dependency);
}
Expand Down Expand Up @@ -107,4 +112,4 @@ private void FilterDependencies(string targetPath, ISet<string> dependencyToRemo
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,9 @@ public async Task CanCreateUserAddLogin()
var logins = await manager.GetLoginsAsync(user);
Assert.NotNull(logins);
Assert.Single(logins);
Assert.Equal(provider, logins.First().LoginProvider);
Assert.Equal(providerKey, logins.First().ProviderKey);
Assert.Equal(display, logins.First().ProviderDisplayName);
Assert.Equal(provider, logins[0].LoginProvider);
Assert.Equal(providerKey, logins[0].ProviderKey);
Assert.Equal(display, logins[0].ProviderDisplayName);
}

/// <summary>
Expand Down Expand Up @@ -644,9 +644,9 @@ public async Task CanCreateUserAddRemoveLogin()
var logins = await manager.GetLoginsAsync(user);
Assert.NotNull(logins);
Assert.Single(logins);
Assert.Equal(login.LoginProvider, logins.Last().LoginProvider);
Assert.Equal(login.ProviderKey, logins.Last().ProviderKey);
Assert.Equal(login.ProviderDisplayName, logins.Last().ProviderDisplayName);
Assert.Equal(login.LoginProvider, logins[^1].LoginProvider);
Assert.Equal(login.ProviderKey, logins[^1].ProviderKey);
Assert.Equal(login.ProviderDisplayName, logins[^1].ProviderDisplayName);
var stamp = await manager.GetSecurityStampAsync(user);
IdentityResultAssert.IsSuccess(await manager.RemoveLoginAsync(user, login.LoginProvider, login.ProviderKey));
Assert.Null(await manager.FindByLoginAsync(login.LoginProvider, login.ProviderKey));
Expand Down Expand Up @@ -772,11 +772,11 @@ public async Task CanReplaceUserClaim()
var userClaims = await manager.GetClaimsAsync(user);
Assert.Equal(1, userClaims.Count);
Claim claim = new Claim("c", "b");
Claim oldClaim = userClaims.FirstOrDefault();
Claim oldClaim = userClaims.Count == 0 ? null : userClaims[0];
IdentityResultAssert.IsSuccess(await manager.ReplaceClaimAsync(user, oldClaim, claim));
var newUserClaims = await manager.GetClaimsAsync(user);
Assert.Equal(1, newUserClaims.Count);
Claim newClaim = newUserClaims.FirstOrDefault();
Claim newClaim = newUserClaims.Count == 0 ? null : newUserClaims[0];
Assert.Equal(claim.Type, newClaim.Type);
Assert.Equal(claim.Value, newClaim.Value);
}
Expand All @@ -800,16 +800,16 @@ public async Task ReplaceUserClaimOnlyAffectsUser()
var userClaims2 = await manager.GetClaimsAsync(user);
Assert.Equal(1, userClaims2.Count);
Claim claim = new Claim("c", "b");
Claim oldClaim = userClaims.FirstOrDefault();
Claim oldClaim = userClaims.Count == 0 ? null : userClaims[0];
IdentityResultAssert.IsSuccess(await manager.ReplaceClaimAsync(user, oldClaim, claim));
var newUserClaims = await manager.GetClaimsAsync(user);
Assert.Equal(1, newUserClaims.Count);
Claim newClaim = newUserClaims.FirstOrDefault();
Claim newClaim = newUserClaims.Count == 0 ? null : newUserClaims[0];
Assert.Equal(claim.Type, newClaim.Type);
Assert.Equal(claim.Value, newClaim.Value);
userClaims2 = await manager.GetClaimsAsync(user2);
Assert.Equal(1, userClaims2.Count);
Claim oldClaim2 = userClaims2.FirstOrDefault();
Claim oldClaim2 = userClaims2.Count == 0 ? null : userClaims2[0];
Assert.Equal("c", oldClaim2.Type);
Assert.Equal("a", oldClaim2.Value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IEnumerable<SelectorModel> FlattenSelectors(ActionModel actionMode
//
// This is fragile wrt application model customizing the data - but no one has
// run into an issue with this and its pretty esoteric.
additionalSelector = new SelectorModel(actionModel.Controller.Selectors.First());
additionalSelector = new SelectorModel(actionModel.Controller.Selectors[0]);
additionalSelector.AttributeRouteModel = null;

for (var i = additionalSelector.ActionConstraints.Count - 1; i >= 0; i--)
Expand Down
5 changes: 2 additions & 3 deletions src/Servers/Kestrel/Core/src/KestrelServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
Expand Down Expand Up @@ -376,9 +375,9 @@ internal void Serialize(Utf8JsonWriter writer)
{
try
{
var cert = CertificateManager.Instance.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true, requireExportable: false)
.FirstOrDefault();
var certs = CertificateManager.Instance.ListCertificates(StoreName.My, StoreLocation.CurrentUser, isValid: true, requireExportable: false);

var cert = certs.Count > 0 ? certs[0] : null;
if (cert is null)
{
logger.UnableToLocateDevelopmentCertificate();
Expand Down

0 comments on commit 8951d73

Please sign in to comment.