Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public virtual async ValueTask<AccessTokenResult> RequestAccessToken()
}

/// <inheritdoc />
[DynamicDependency(JsonSerialized, typeof(AccessToken))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter where exactly we add the DynamicDependency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to think about it is - if the trimmer decides not to trim away RequestAccessToken because it's called by user code directly or indirectly, then the types declared as dynamic dependencies do not get trimmed. Usually you want to put it close to where the referenced type gets used so you're not rooting more things than you need to. I'm guessing in this case InternalAccessTokenResult references AccessToken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing in this case InternalAccessTokenResult references AccessToken?

Exactly, that's what's in the stack trace. But I wasn't sure if it needed to be on a method to work. Thanks for the clarification!

   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalAccessTokenResult, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , InternalAccessTokenResult& )
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalAccessTokenResult, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].TryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , InternalAccessTokenResult& )
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalAccessTokenResult, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.InternalAccessTokenResult, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ReadCoreAsObject(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
   at System.Text.Json.JsonSerializer.ReadCore[Object](JsonConverter , Utf8JsonReader& , JsonSerializerOptions , ReadStack& )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I wasn't sure if it needed to be on a method to work.

Looks like that is in fact the case:

Attribute 'DynamicDependency' is not valid on this declaration type. It is only valid on 'constructor, method, field' declarations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted back, any objections?

827bd4d

[DynamicDependency(JsonSerialized, typeof(AccessTokenRequestOptions))]
public virtual async ValueTask<AccessTokenResult> RequestAccessToken(AccessTokenRequestOptions options)
{
Expand Down