From 244ffb4950c36c5515b2fbbff73d825c2b5a9fad Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 16:52:28 -0700 Subject: [PATCH 1/9] Add action to generate API diff analysis --- .github/workflows/apidiff.yml | 95 +++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/apidiff.yml diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml new file mode 100644 index 00000000..b1cf0aa6 --- /dev/null +++ b/.github/workflows/apidiff.yml @@ -0,0 +1,95 @@ +name: PR API diff + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + api-diff: + runs-on: windows-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Install generator + run: dotnet tool install --global dotMorten.OmdGenerator + + - name: Generate API diff + shell: bash + run: | + generateomd \ + /source=src/MyLibrary \ + /gitRepo=${{ github.server_url }}/${{ github.repository }} \ + /sourceRef=${{ github.event.pull_request.head.sha }} \ + /compareRef=${{ github.event.pull_request.base.sha }} \ + /format=md \ + /output=api-diff + + - name: Check whether API changes were found + id: api_diff + shell: bash + run: | + if grep -q '^namespace ' api-diff.md; then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=false" >> "$GITHUB_OUTPUT" + fi + + - name: Create or update PR comment + if: steps.api_diff.outputs.has_changes == 'true' + uses: actions/github-script@v7 + env: + COMMENT_MARKER: + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const marker = process.env.COMMENT_MARKER; + const diff = fs.readFileSync('api-diff.md', 'utf8').trim(); + const body = [ + marker, + '## API changes', + '', + diff + ].join('\n'); + + const { owner, repo } = context.repo; + const issue_number = context.payload.pull_request.number; + + const comments = await github.paginate(github.rest.issues.listComments, { + owner, + repo, + issue_number, + per_page: 100 + }); + + const existing = comments.find(comment => + comment.user.type === 'Bot' && comment.body.includes(marker)); + + if (existing) { + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existing.id, + body + }); + } else { + await github.rest.issues.createComment({ + owner, + repo, + issue_number, + body + }); + } From eb37f893d89f2d5106d80c3672c8a67cde4a2d3c Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 16:54:57 -0700 Subject: [PATCH 2/9] Test to be undone --- src/WinUIEx/WindowManager.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/WinUIEx/WindowManager.cs b/src/WinUIEx/WindowManager.cs index ca31e1d4..f2df1dbd 100644 --- a/src/WinUIEx/WindowManager.cs +++ b/src/WinUIEx/WindowManager.cs @@ -38,6 +38,13 @@ private static bool TryGetWindowManager(Window window, [MaybeNullWhen(false)] ou manager = null; return false; } + + /// + /// This is just a test. DO NOT MERGE. + /// + public static bool TestProperty { get; set; } + + public Task TestAsync() => throw new System.NotImplementedException("TODO"); /// /// Gets (or creates) a window manager for the specific window. From 9ac255a2a69938f1a67ae15b734afd4e49384a32 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 16:57:14 -0700 Subject: [PATCH 3/9] Update apidiff.yml --- .github/workflows/apidiff.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index b1cf0aa6..2ef9e404 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -30,12 +30,12 @@ jobs: shell: bash run: | generateomd \ - /source=src/MyLibrary \ - /gitRepo=${{ github.server_url }}/${{ github.repository }} \ - /sourceRef=${{ github.event.pull_request.head.sha }} \ - /compareRef=${{ github.event.pull_request.base.sha }} \ - /format=md \ - /output=api-diff + --source=src/WinUIEx \ + --gitRepo=${{ github.server_url }}/${{ github.repository }} \ + --sourceRef=${{ github.event.pull_request.head.sha }} \ + --compareRef=${{ github.event.pull_request.base.sha }} \ + --format=md \ + --output=api-diff - name: Check whether API changes were found id: api_diff From 02287db800783075ca84bab2f286b08e7fcc7f14 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 16:57:59 -0700 Subject: [PATCH 4/9] Update WindowManager.cs --- src/WinUIEx/WindowManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinUIEx/WindowManager.cs b/src/WinUIEx/WindowManager.cs index f2df1dbd..53ce6b75 100644 --- a/src/WinUIEx/WindowManager.cs +++ b/src/WinUIEx/WindowManager.cs @@ -44,7 +44,7 @@ private static bool TryGetWindowManager(Window window, [MaybeNullWhen(false)] ou /// public static bool TestProperty { get; set; } - public Task TestAsync() => throw new System.NotImplementedException("TODO"); + public string TestMethod() => throw new System.NotImplementedException("TODO"); /// /// Gets (or creates) a window manager for the specific window. From 4f7248eb0c635c43c833fd278eb5da8b61db5753 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 16:59:32 -0700 Subject: [PATCH 5/9] Update apidiff.yml --- .github/workflows/apidiff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index 2ef9e404..d46c6997 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -30,7 +30,7 @@ jobs: shell: bash run: | generateomd \ - --source=src/WinUIEx \ + --source=src/WinUIEx/ \ --gitRepo=${{ github.server_url }}/${{ github.repository }} \ --sourceRef=${{ github.event.pull_request.head.sha }} \ --compareRef=${{ github.event.pull_request.base.sha }} \ From cca5cdc95009110635b7478fd8dcc1ba81dff4ee Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 17:04:24 -0700 Subject: [PATCH 6/9] Update apidiff.yml --- .github/workflows/apidiff.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index d46c6997..185f178e 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -13,11 +13,6 @@ jobs: runs-on: windows-latest steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up .NET uses: actions/setup-dotnet@v4 with: From 3f718eec79b8225173560b249d57104dcfd4284b Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 17:07:17 -0700 Subject: [PATCH 7/9] Update WindowManager.cs --- src/WinUIEx/WindowManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinUIEx/WindowManager.cs b/src/WinUIEx/WindowManager.cs index 53ce6b75..0a807256 100644 --- a/src/WinUIEx/WindowManager.cs +++ b/src/WinUIEx/WindowManager.cs @@ -630,7 +630,7 @@ public Microsoft.UI.Windowing.AppWindowPresenterKind PresenterKind /// /// Raised if the Z order of the window changes. /// - public event EventHandler? ZOrderChanged; + internal event EventHandler? ZOrderChanged; } From bf609f03b01be028f8c73063b08b91ed03b86d04 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 17:09:49 -0700 Subject: [PATCH 8/9] Update WindowManager.cs --- src/WinUIEx/WindowManager.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/WinUIEx/WindowManager.cs b/src/WinUIEx/WindowManager.cs index 0a807256..ca31e1d4 100644 --- a/src/WinUIEx/WindowManager.cs +++ b/src/WinUIEx/WindowManager.cs @@ -38,13 +38,6 @@ private static bool TryGetWindowManager(Window window, [MaybeNullWhen(false)] ou manager = null; return false; } - - /// - /// This is just a test. DO NOT MERGE. - /// - public static bool TestProperty { get; set; } - - public string TestMethod() => throw new System.NotImplementedException("TODO"); /// /// Gets (or creates) a window manager for the specific window. @@ -630,7 +623,7 @@ public Microsoft.UI.Windowing.AppWindowPresenterKind PresenterKind /// /// Raised if the Z order of the window changes. /// - internal event EventHandler? ZOrderChanged; + public event EventHandler? ZOrderChanged; } From 7688aaad88224000e7d09217cad47b88f490290d Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Sat, 23 May 2026 17:15:18 -0700 Subject: [PATCH 9/9] Update apidiff.yml --- .github/workflows/apidiff.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index 185f178e..6c31927b 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -43,23 +43,18 @@ jobs: fi - name: Create or update PR comment - if: steps.api_diff.outputs.has_changes == 'true' uses: actions/github-script@v7 env: COMMENT_MARKER: + HAS_CHANGES: ${{ steps.api_diff.outputs.has_changes }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); const marker = process.env.COMMENT_MARKER; + const hasChanges = process.env.HAS_CHANGES === 'true'; const diff = fs.readFileSync('api-diff.md', 'utf8').trim(); - const body = [ - marker, - '## API changes', - '', - diff - ].join('\n'); - + const { owner, repo } = context.repo; const issue_number = context.payload.pull_request.number; @@ -73,6 +68,24 @@ jobs: const existing = comments.find(comment => comment.user.type === 'Bot' && comment.body.includes(marker)); + if (!hasChanges && !existing) { + return; + } + + const body = hasChanges + ? [ + marker, + '## API changes', + '', + diff + ].join('\n') + : [ + marker, + '## API changes', + '', + 'No API changes are currently detected in this pull request.' + ].join('\n'); + if (existing) { await github.rest.issues.updateComment({ owner,