Skip to content

Commit 95abaa6

Browse files
fix
1 parent 3d5729b commit 95abaa6

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/client/Microsoft.Identity.Client/AuthenticationResult.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public partial class AuthenticationResult
4343
/// <param name="claimsPrincipal">Claims from the ID token</param>
4444
/// <param name="spaAuthCode">Auth Code returned by the Microsoft identity platform when you use AcquireTokenByAuthorizationCode.WithSpaAuthorizationCode(). This auth code is meant to be redeemed by the frontend code. See https://aka.ms/msal-net/spa-auth-code</param>
4545
/// <param name="additionalResponseParameters">Other properties from the token response.</param>
46-
[Obsolete("Direct constructor use is deprecated.", error: false)]
47-
[EditorBrowsable(EditorBrowsableState.Never)]
4846
public AuthenticationResult( // for backwards compat with 4.16-
4947
string accessToken,
5048
bool isExtendedLifeTimeToken,
@@ -98,8 +96,6 @@ public partial class AuthenticationResult
9896
/// <param name="authenticationResultMetadata">Contains metadata related to the Authentication Result.</param>
9997
/// <param name="tokenType">The token type, defaults to Bearer. Note: this property is experimental and may change in future versions of the library.</param>
10098
/// <remarks>For backwards compatibility with MSAL 4.17-4.20 </remarks>
101-
[Obsolete("Direct constructor use is deprecated.", error: false)]
102-
[EditorBrowsable(EditorBrowsableState.Never)]
10399
public AuthenticationResult(
104100
string accessToken,
105101
bool isExtendedLifeTimeToken,

tests/Microsoft.Identity.Test.Unit/PublicApiTests/AuthenticationResultTests.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ namespace Microsoft.Identity.Test.Unit.PublicApiTests
1818
public class AuthenticationResultTests : TestBase
1919
{
2020

21+
[TestMethod]
22+
public void PublicTestConstructorCoversAllProperties()
23+
{
24+
// The first public ctor that is meant only for tests (“for-test”)
25+
var ctorParameters = typeof(AuthenticationResult)
26+
.GetConstructors()
27+
.First(ctor => ctor.GetParameters().Length > 3)
28+
.GetParameters();
29+
30+
var classProperties = typeof(AuthenticationResult)
31+
.GetProperties()
32+
.Where(p => p.GetCustomAttribute(typeof(ObsoleteAttribute)) == null)
33+
.Where(p => p.SetMethod == null || p.SetMethod.IsPublic)
34+
.Where(p => p.Name != nameof(AuthenticationResult.BindingCertificate));
35+
36+
// +2 for the 2 obsolete ExtendedExpires* props that are deliberately
37+
// not represented in the ctor.
38+
Assert.AreEqual(
39+
ctorParameters.Length,
40+
classProperties.Count() + 2,
41+
"The <for-test> constructor should include all public-settable or read-only properties of AuthenticationResult (except BindingCertificate and the obsolete ExtendedExpires* pair).");
42+
}
43+
2144
[TestMethod]
2245
public void GetAuthorizationHeader()
2346
{
24-
#pragma warning disable CS0618 // exercising obsolete constructors until full deprecation
2547
var ar = new AuthenticationResult(
2648
"at",
2749
false,
@@ -64,7 +86,6 @@ public void GetHybridSpaAuthCode()
6486
"one for backwards compat with 4.17+ and one for 4.16 and below")]
6587
public void AuthenticationResult_PublicApi()
6688
{
67-
#pragma warning disable CS0618 // exercising obsolete constructors until full deprecation
6889
// old constructor, before 4.16
6990
var ar1 = new AuthenticationResult(
7091
"at",

0 commit comments

Comments
 (0)