Skip to content

[STJ] Account for F# CompilationMappingAttribute now supporting multiple declarations. #114961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 26, 2025

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Apr 23, 2025

Addresses #114824 for .NET 10.

@Copilot Copilot AI review requested due to automatic review settings April 23, 2025 15:56
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates how the code retrieves the FSharp compilation mapping attributes to support multiple attribute declarations for .NET 10.

  • In GetFSharpCompilationMappingAttribute, the code now retrieves all attributes and returns the first explicit declaration.
  • In GetFSharpCoreAssembly, the attribute lookup is modified to ignore inherited attributes.
Files not reviewed (1)
  • src/libraries/System.Text.Json/tests/System.Text.Json.FSharp.Tests/RecordTests.fs: Language not supported
Comments suppressed due to low confidence (2)

src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/FSharpCoreReflectionProxy.cs:208

  • Switching from GetCustomAttribute with inherit:true to retrieving all attributes with inherit:false and using the first one might overlook multiple explicit declarations. Please verify that only the first attribute is sufficient for the intended behavior.
object[] attributes = type.GetCustomAttributes(_compilationMappingAttributeType, inherit: false);

src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/FSharpCoreReflectionProxy.cs:218

  • Changing the attribute lookup from inherit:true to inherit:false might omit inherited attributes that could be relevant. Confirm that this adjustment aligns with the intended F# core assembly resolution behavior.
foreach (Attribute attr in type.GetCustomAttributes(inherit: false))

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

@eiriktsarpalis eiriktsarpalis changed the title Account for CompilationMappingAttribute supporting multiple declarations. [STJ] Account for F# CompilationMappingAttribute supporting multiple declarations. Apr 23, 2025
@eiriktsarpalis eiriktsarpalis changed the title [STJ] Account for F# CompilationMappingAttribute supporting multiple declarations. [STJ] Account for F# CompilationMappingAttribute now supporting multiple declarations. Apr 23, 2025
@jeffhandley
Copy link
Member

When you say, "Partially addresses," do you mean that it only addresses the issue for .NET 10, or do you mean that there are scenarios in .NET 10 still not addressed with this as well?

@eiriktsarpalis
Copy link
Member Author

When you say, "Partially addresses," do you mean that it only addresses the issue for .NET 10, or do you mean that there are scenarios in .NET 10 still not addressed with this as well?

I sorry, I should have said this addresses it fully for 10, but it shouldn't be used to close the underlying issue as we're working out resolution strategies for .NET 8 and 9.

@jeffhandley
Copy link
Member

/ba-g The failures are all known and unrelated and they are not transient.

@eiriktsarpalis eiriktsarpalis merged commit 1a7343c into dotnet:main Apr 26, 2025
78 of 85 checks passed
@eiriktsarpalis eiriktsarpalis deleted the stj-fsharp-fixes branch April 26, 2025 11:59
@eiriktsarpalis
Copy link
Member Author

/backport to release/9.0-staging

Copy link
Contributor

Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/14681001692

@eiriktsarpalis
Copy link
Member Author

/backport to release/8.0-staging

Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/14681004374

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants