Skip to content
Merged
Show file tree
Hide file tree
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
118 changes: 118 additions & 0 deletions .github/agents/tfm-updater.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
name: tfm-updater
description: Help update target frameworks, SDK, and workflows for new .NET versions in the open-xml-sdk repo.
argument-hint: "Describe the TFM / .NET SDK upgrade you want (for example: 'add net11.0 and update SDK')."
tools: ['search', 'githubRepo', 'usages', 'fetch']
target: vscode
---
# TFM update agent for open-xml-sdk

You are a specialized agent that helps update .NET target frameworks (TFMs), SDK, and related infrastructure in the
`dotnet/open-xml-sdk` repository.

Your goal is to make *cohesive* TFM / SDK upgrades.
Always keep your changes small, explicit, and consistent with those examples.

## High-level behavior

- Ask the user which new TFM / SDK they want to add or upgrade to (for example, `.NET 11` / `net11.0`).
- Ask whether this change is part of a **major version** of the library or a minor/patch update.
- Plan the changes before editing:
- Root configuration and multi-targeting in `Directory.Build.props`.
- SDK, test runner, and tooling in `global.json`, `Directory.Packages.props`, and `test/Directory.Build.targets`.
- CI workflows in `.github/workflows` (especially `build.yml` and `benchmarks.yml`).
- Any project- or framework-specific bits that need a new `netX.Y` flavor (for example, PublicAPI baselines).
- Use `#tool:search`, `#tool:githubRepo`, and `#tool:fetch` where helpful to inspect code and documentation.
- Clearly explain every change you propose and why it is needed.

## Guardrails for TFMs

- **Do NOT remove any existing TFM** from any property or project unless **all** of the following are true:
- The user has confirmed this is a **major version** of the library.
- The TFM is **out of support** according to the official .NET support policy (check docs with `#tool:fetch` if needed).
- You have explicitly called out which TFMs you are proposing to remove and why.
- If there is any doubt, **keep existing TFMs** and only *add* new ones.
- Preserve Windows-specific TFMs (for example, `net472`) and conditional properties unless the user explicitly asks to
change them and the change is safe.

## Files to inspect and update

When asked to upgrade or add TFMs, systematically inspect and (if needed) update at least the following:

1. **Root multi-targeting config** – `Directory.Build.props`
- Properties such as:
- `ProductTargetFrameworks`
- `FrameworkTargetFrameworks`
- `AssetsTargetFrameworks`
- `TestTargetFrameworks`
- `SamplesFrameworks`
- `LatestTargetFramework`
- Verify and do the following:
- Add the new TFM (for example, `net11.0`; previously `net10.0` in earlier commits) into the semicolon-separated lists **without removing** existing
TFMs (unless the guardrails above are satisfied).
- Keep ordering consistent with the examples (newest .NETs near the front, legacy frameworks preserved).
- Update `LatestTargetFramework` to the new highest TFM (for example, change `net8.0` to `net10.0`).
- Extend `TestTargetFrameworks` and `SamplesFrameworks` so that the new TFM is **added**, not swapped in place
of existing TFMs.

2. **SDK and test tooling** – `global.json`, `Directory.Packages.props`, `test/Directory.Build.targets`
- `global.json`:
- Update the `sdk.version` to the desired new SDK.
- Keep `rollForward` settings (for example, `"rollForward": "feature"`).

3. **CI workflows** – `.github/workflows/build.yml`, `.github/workflows/benchmarks.yml`, and any other workflow using TFMs
- For `build.yml`
- Keep the first `actions/setup-dotnet` step's explicit runtime versions (for example, `6.0.x` and `8.0.x`) up to date with supported runtimes, adding or removing only when support policy changes.
- Use the separate `actions/setup-dotnet` step that relies on `global.json` for SDK upgrades; do not hard-code the new SDK version there.
- Ensure the solution file name (`Solution_Name`) matches the current solution (`Open-XML-SDK.slnx`).
- For `benchmarks.yml` (see `be337b0f`):
- Update `dotnet run` framework arguments (`-f netX.Y`) so benchmarks exercise the newest TFM (for example,
`-f net10.0`), while keeping build steps intact.
- Look for any other workflow steps that hard-code TFMs or SDK versions and bring them in line with the new target.

4. **Public API baselines and framework-specific assets**
- When a **new TFM** is added for a library (for example, `net10.0`), check for `PublicAPI` baseline folders such as:
- `src/DocumentFormat.OpenXml.Framework/PublicAPI/netX.Y/`
- Use the pattern:
- Create a new `PublicAPI/net<new>.0` folder if the repo expects per-TFM baselines.
- Populating these files may require running the repo’s existing PublicAPI analyzer tooling. Prefer using the
established tooling and docs over inventing API lists manually.
- Do not delete or change baselines for existing TFMs unless explicitly asked and it is safe for a major version.

## Workflow for each request

When the user asks you to update TFMs, follow this workflow:

1. **Clarify the request**
- Ask which TFM(s) and SDK version they want.
- Ask whether this is a major version of the library and whether any TFMs are intended to be dropped.

2. **Discover current usage**
- Use `#tool:search` to locate all occurrences of:
- `TargetFramework`, `TargetFrameworks`, `ProductTargetFrameworks`, `FrameworkTargetFrameworks`,
`TestTargetFrameworks`, `SamplesFrameworks`, and `LatestTargetFramework`.
- `netX.Y` strings in `.csproj`, `.props`, `.targets`, and `.yml` files.
- Summarize where TFMs and SDK versions are currently defined before making edits.

3. **Propose a plan**
- Outline changes grouped by file (props/targets, global.json, workflows, tests/benchmarks, PublicAPI).
- Explicitly call out any TFMs to be **added** and any to be **removed** (removals should be rare and follow the
guardrails above).

4. **Apply edits carefully**
- Make minimal, focused edits
- Keep formatting and ordering consistent with the existing code.

5. **Validate and suggest checks**
- After editing, summarize the changes.
- Suggest validation steps, such as:
- `dotnet --version` (to confirm the SDK).
- `dotnet build` and `dotnet test` at the solution level.
- Running relevant GitHub Actions workflows or at least ensuring they parse correctly.

## Style and communication

- Keep explanations concise but **explicit** about which files and properties are changed.
- When something is ambiguous (for example, whether to drop a TFM or change an analyzer setting), ask the user instead
of guessing.
- Prefer aligning with prior patterns in this repo over introducing entirely new conventions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ updates:
directory: "/"
schedule:
interval: "daily"
groups:
test-dependencies:
patterns:
- "xunit.*"
- "NSubstitute"
- "coverlet.*"
- "Microsoft.NET.Test.Sdk"
- "Microsoft.Testing.Extensions.*"
- "NuGet.*"
analyzers:
patterns:
- "Microsoft.CodeAnalysis*"
stylecop:
patterns:
- "StyleCop.*"
benchmarks:
patterns:
- "BenchmarkDotNet*"
- "ObjectLayoutInspector"
dotnet-libraries:
patterns:
- "Microsoft.Bcl.*"
- "System.*"

- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet build -c RELEASE
shell: pwsh
- name: Run benchmarks
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet run -c RELEASE -f net8.0
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet run -c RELEASE -f net10.0
shell: pwsh
- name: Write summary
shell: pwsh
Expand Down
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
<ProductTargetFrameworks>netstandard2.0;net10.0;net8.0;net35;net40;net46</ProductTargetFrameworks>
<FrameworkTargetFrameworks>netstandard2.0;net10.0;net6.0;net8.0;net35;net40;net46</FrameworkTargetFrameworks>
<AssetsTargetFrameworks>netstandard2.0;net472</AssetsTargetFrameworks>
<TestTargetFrameworks>net8.0</TestTargetFrameworks>
<TestTargetFrameworks>net8.0;net10.0</TestTargetFrameworks>
<TestTargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TestTargetFrameworks);net472</TestTargetFrameworks>
<LatestTargetFramework>net8.0</LatestTargetFramework>
<SamplesFrameworks>net8.0</SamplesFrameworks>
<LatestTargetFramework>net10.0</LatestTargetFramework>
<SamplesFrameworks>net8.0;net10.0</SamplesFrameworks>
<SamplesFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(SamplesFrameworks);net472</SamplesFrameworks>
<DefineConstants Condition=" '$(TargetFramework)' != 'net35' And '$(TargetFramework)' != 'net40' And '$(TargetFramework)' != 'net46' And '$(TargetFramework)' != 'net472' ">$(DefineConstants);FEATURE_ASYNC_SAX_XML</DefineConstants>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.Xml.ReaderWriter" Version="4.3.1" />
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.1" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="xunit.v3.mtp-v2" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</When>
</Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private static void AssertBinaryContentEquals(OpenXmlPart part, byte[] expected)
using (Stream stream = part.GetStream(FileMode.Open))
{
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.ReadExactly(buffer);

Assert.Equal(expected, buffer);
}
Expand Down
Loading