Skip to content

Commit

Permalink
removed equals and gethashcode
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLozensky committed Dec 1, 2023
1 parent e560977 commit d83afd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,9 @@ public ManagedIdentityOptions Clone()
{
return new ManagedIdentityOptions
{
ManagedIdentityType = this.ManagedIdentityType,
ClientId = this.ClientId
ManagedIdentityType = ManagedIdentityType,
ClientId = ClientId
};
}

/// <summary>
/// Ensures any <see cref="ManagedIdentityOptions"/> object is equal if all fields hold the same values.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
ManagedIdentityOptions other = (ManagedIdentityOptions)obj;
return ManagedIdentityType == other.ManagedIdentityType &&
ClientId == other.ClientId;
}

/// <summary>
/// Returns the hash code for the instance based on the values of its fields.
/// </summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode()
{
return new { ManagedIdentityType, ClientId }.GetHashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public void CloneClonesAllProperties()
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ExtraQueryParameters, downstreamApiClone.AcquireTokenOptions.ExtraQueryParameters);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ForceRefresh, downstreamApiClone.AcquireTokenOptions.ForceRefresh);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.LongRunningWebApiSessionKey, downstreamApiClone.AcquireTokenOptions.LongRunningWebApiSessionKey);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ManagedIdentity, downstreamApiClone.AcquireTokenOptions.ManagedIdentity);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ManagedIdentity.ManagedIdentityType, downstreamApiClone.AcquireTokenOptions.ManagedIdentity.ManagedIdentityType);

Check warning on line 79 in test/Microsoft.Identity.Abstractions.Tests/DownstreamApiTests.cs

View workflow job for this annotation

GitHub Actions / Abstractions GitHub Action Test

Dereference of a possibly null reference.

Check warning on line 79 in test/Microsoft.Identity.Abstractions.Tests/DownstreamApiTests.cs

View workflow job for this annotation

GitHub Actions / Abstractions GitHub Action Test

Dereference of a possibly null reference.
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.ManagedIdentity.ClientId, downstreamApiClone.AcquireTokenOptions.ManagedIdentity.ClientId);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.PopPublicKey, downstreamApiClone.AcquireTokenOptions.PopPublicKey);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.PopClaim, downstreamApiClone.AcquireTokenOptions.PopClaim);
Assert.Equal(downstreamApiOptions.AcquireTokenOptions.Tenant, downstreamApiClone.AcquireTokenOptions.Tenant);
Expand Down Expand Up @@ -154,4 +155,4 @@ public CustomAcquireTokenOptions() : base() { }

public CustomAcquireTokenOptions(CustomAcquireTokenOptions other) : base(other) { }
}
}
}

0 comments on commit d83afd2

Please sign in to comment.