-
Notifications
You must be signed in to change notification settings - Fork 820
[WIP] Auto-generate IlLink.Substitutions.xml to Remove F# Metadata Resources #18592
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
base: main
Are you sure you want to change the base?
Conversation
@copilot please do it |
✅ No release notes required |
@copilot try now |
@copilot try now |
Co-authored-by: T-Gro <[email protected]>
I've implemented the requested task to auto-generate ILLink.Substitutions.xml for removing F# metadata resources during trimming. The implementation includes:
Changes are in commit 3aff8db. Next I'll be working on adding tests in the AheadOfTime/Trimming folder. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: T-Gro <[email protected]>
/// Assembly name to use when generating resource names to be removed. | ||
/// </summary> | ||
[<Required>] | ||
member _.AssemblyName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a member val
to have an F# auto-implemented property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to use F# auto-implemented properties with member val
syntax for all the properties in the task. These changes can be seen in commit 74bce89.
member _.IntermediateOutputPath | ||
with get () = _intermediateOutputPath | ||
and set value = _intermediateOutputPath <- value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a member val
to have an F# auto-implemented property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the IntermediateOutputPath property to use member val
syntax along with the other properties in commit 74bce89.
member _.GeneratedItems | ||
with get () = _generatedItems | ||
and set value = _generatedItems <- value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a member val
to have an F# auto-implemented property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The GeneratedItems property has been updated to use member val
syntax along with the other properties in commit 74bce89.
let resourcePrefixes = [| | ||
"FSharpSignatureData" | ||
"FSharpSignatureDataB" | ||
"FSharpSignatureCompressedData" | ||
"FSharpSignatureCompressedDataB" | ||
"FSharpOptimizationData" | ||
"FSharpOptimizationDataB" | ||
"FSharpOptimizationCompressedData" | ||
"FSharpOptimizationCompressedDataB" | ||
"FSharpOptimizationInfo" | ||
"FSharpSignatureInfo" | ||
|] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the F# array builder syntax to make it more apparent that those are combinations of:
Signature x Optimization
Compressed vs "" (blank)
Data vs DataB
and then yield the last two "..Info" special cases.
That way, it will be easier to see that indeed all combinations are covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored the resource prefixes array to use a more structured approach with F# comprehension expressions to clearly show all combinations of prefix types (Signature/Optimization), compression (""/Compressed), and data types (Data/DataB). This makes it clearer that all combinations are covered. The Info variants are now added separately as they follow a different pattern. These changes are in commit 74bce89.
|] | ||
|
||
// Generate the XML content | ||
let sb = StringBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size can be pre-detrmined upfront, use an overload of StringBuilder that takes initial capacity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code to pre-allocate the StringBuilder capacity by using the appropriate constructor overload with an initial capacity of 4096, which should be more than enough for our XML content. This change is in commit 74bce89.
// Close all resource tags | ||
for _ in resourcePrefixes do | ||
sb.Append("</resource>") |> ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just wrong. Each resource should be closed on the same line it is opened. What you did would produce invalid XML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right. I've fixed the XML generation to properly close each resource tag on the same line it's opened, producing valid XML like: <resource name="..." action="remove"></resource>
. This change is in commit 74bce89.
<RuntimeIdentifier>win-x64</RuntimeIdentifier> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to make sure that the new targets and freshly build FSharpBuildAssemblyFile is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the test project to explicitly set the FSharpBuildAssemblyFile property to point to the freshly built FSharp.Build.dll, and added imports for the custom targets files directly from the repository to ensure it uses the latest version with our new task. These changes are in commit 74bce89.
Co-authored-by: T-Gro <[email protected]>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
/// <summary> | ||
/// Generated embedded resource items. | ||
/// </summary> | ||
[<o>] | ||
member val GeneratedItems = [| |] : ITaskItem[] with get, set | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type o
is not defined, this is wrong and causes a build failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original issue description:
Fixes #18591.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.