Skip to content

Commit 0cb97cc

Browse files
authored
feat(blex): port Blex project #13865 (#13875)
1 parent 06895a5 commit 0cb97cc

322 files changed

Lines changed: 36738 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/agents/dependency-update.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ assembly. These are floors for the oldest supported SDK:
5858
| `Microsoft.CodeAnalysis.Analyzers` | 3.3.3 | `Bit.BlazorUI.SourceGenerators`, `Bit.SourceGenerators` |
5959
| `Microsoft.CodeAnalysis.CSharp.Workspaces` | 4.3.1 | `Bit.BlazorUI.SourceGenerators`, `Bit.SourceGenerators` |
6060
| `Microsoft.CodeAnalysis.Workspaces.Common` | 4.3.1 | `Bit.CodeAnalyzers` |
61-
| `Microsoft.CodeAnalysis.CSharp` | 4.8.0 | `Bit.Brouter.Generators` + its test project (must match) |
61+
| `Microsoft.CodeAnalysis.CSharp` | 4.8.0 | `Bit.Brouter.Generators`, `Bit.Blex.Generators` + their test projects, and `Bit.Blex.Demo.Server` (runs the Blex generator for its MCP server) (must match) |
6262
| `Microsoft.CodeAnalysis.CSharp` | 4.14.0 | `Bit.CodeAnalyzers` |
6363
| `Microsoft.Build.Utilities.Core` | 17.7.2 | `Bit.Butil.Build` |
6464

‎.github/agents/test-platform.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ does not serve silently gets the newest one it does.
334334
`feat(release): v-X.Y.Z` commit on `develop` has its tag: an untagged release is answered by the previous one,
335335
without a word.
336336
2. **What it does serve.** `mcp -McpVersion X.Y.Z` for each. The library tools (`Search*` and `Get*` of BlazorUI,
337-
Brouter, Butil, Bswup, Bmotion and - from the first release that ships it - Bonboarding) and the source tools (`FindBitPlatformSymbols`, `GetBitPlatformSymbolSource`,
337+
Brouter, Butil, Bswup, Bmotion and - from the first release that ships them - Bonboarding and Blex) and the source tools (`FindBitPlatformSymbols`, `GetBitPlatformSymbolSource`,
338338
`SearchBitPlatformCode`) must all be there. Only the five shared ones (`AskGitHubRepository`,
339339
`SendBitPlatformFeedback`, `microsoft_docs_*`) means no release is served at all, and the README's
340340
*PlatformWebsite's MCP* section says why that happens. The server version it reports is the website's own build,
@@ -353,7 +353,7 @@ does not serve silently gets the newest one it does.
353353
4. **The answers are good.** Put one real task to each library's `Search` tool, worded the way a developer would
354354
describe it - BlazorUI "a dropdown the user can also type into", Butil "copy text to the clipboard", Bmotion "fade
355355
a list item in", Brouter "a route parameter that must be a number", Bswup "show the download progress of the app's
356-
update", Bonboarding "a step that waits for a panel that loads later" - follow up with the `Get` tool it points to, and ask `SearchBitPlatformCode` about the Boilerplate. An
356+
update", Bonboarding "a step that waits for a panel that loads later", Blex "a counter whose value survives a page reload" - follow up with the `Get` tool it points to, and ask `SearchBitPlatformCode` about the Boilerplate. An
357357
answer must be on topic, specific and true to the version asked for; one that answers wrongly is a failure too.
358358

359359
Like an E2E failure, an MCP problem is fixed in `src/Websites/Platform` or in the library's own MCP server, and goes

‎.github/copilot-instructions.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
## Rules
4747

4848
**RULE 1:** If a task (question, code modification or review) involves the use of bit BlazorUI components (e.g., `BitButton`, `BitTooltip`, `BitTextField`),
49-
or refers to `bitplatform`, `bit Bswup`, `bit Butil`, `bit Bmotion`, `bit Bonboarding`, `bit Brouter`, or `bit Boilerplate`, or involves UI components without explicitly specifying their UI toolkit,
50-
you **MUST** use the `bitplatform` MCP server's tools - start with the matching `Search<Library>` tool (e.g. `SearchBitBlazorUI`, `SearchBswup`, `SearchButil`, `SearchBmotion`, `SearchBonboarding`, `SearchBrouter`) and follow the calls it names - to find the correct implementation and usage patterns before writing or changing any code.
49+
or refers to `bitplatform`, `bit Bswup`, `bit Butil`, `bit Bmotion`, `bit Bonboarding`, `bit Blex`, `bit Brouter`, or `bit Boilerplate`, or involves UI components without explicitly specifying their UI toolkit,
50+
you **MUST** use the `bitplatform` MCP server's tools - start with the matching `Search<Library>` tool (e.g. `SearchBitBlazorUI`, `SearchBswup`, `SearchButil`, `SearchBmotion`, `SearchBonboarding`, `SearchBlex`, `SearchBrouter`) and follow the calls it names - to find the correct implementation and usage patterns before writing or changing any code.
5151

5252
**End of RULE 1**
5353

‎.github/workflows/all.cd.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ jobs:
5353
with:
5454
prerelease_packages: ${{ inputs.prerelease_packages }}
5555

56+
blex_demo:
57+
name: blex demo
58+
if: inputs.server
59+
uses: ./.github/workflows/blex.demo.cd.yml
60+
secrets: inherit
61+
5662
bmotion_demo:
5763
name: bmotion demo
5864
if: inputs.server

‎.github/workflows/all.ci.yml‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ on:
5151
description: Bmotion solution
5252
type: boolean
5353
default: true
54+
blex:
55+
description: Blex solution
56+
type: boolean
57+
default: true
5458
bonboarding:
5559
description: Bonboarding solution
5660
type: boolean
@@ -571,6 +575,31 @@ jobs:
571575
dotnet build src/Bmotion/Bit.Bmotion/Bit.Bmotion.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
572576
dotnet pack src/Bmotion/Bit.Bmotion/Bit.Bmotion.csproj --output ./packages --configuration Release
573577
578+
- name: Build and pack Blex
579+
run: |
580+
dotnet build src/Blex/Bit.Blex/Bit.Blex.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
581+
dotnet pack src/Blex/Bit.Blex/Bit.Blex.csproj --output ./packages --configuration Release
582+
583+
- name: Build and pack Blex.Generators
584+
run: |
585+
dotnet build src/Blex/Bit.Blex.Generators/Bit.Blex.Generators.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
586+
dotnet pack src/Blex/Bit.Blex.Generators/Bit.Blex.Generators.csproj --output ./packages --configuration Release
587+
588+
- name: Build and pack Blex.Blazor
589+
run: |
590+
dotnet build src/Blex/Bit.Blex.Blazor/Bit.Blex.Blazor.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
591+
dotnet pack src/Blex/Bit.Blex.Blazor/Bit.Blex.Blazor.csproj --output ./packages --configuration Release
592+
593+
- name: Build and pack Blex.Maui
594+
run: |
595+
dotnet build src/Blex/Bit.Blex.Maui/Bit.Blex.Maui.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
596+
dotnet pack src/Blex/Bit.Blex.Maui/Bit.Blex.Maui.csproj --output ./packages --configuration Release
597+
598+
- name: Build and pack Blex.Testing
599+
run: |
600+
dotnet build src/Blex/Bit.Blex.Testing/Bit.Blex.Testing.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
601+
dotnet pack src/Blex/Bit.Blex.Testing/Bit.Blex.Testing.csproj --output ./packages --configuration Release
602+
574603
- name: Build and pack Bonboarding
575604
run: |
576605
dotnet build src/Bonboarding/Bit.Bonboarding/Bit.Bonboarding.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
@@ -634,6 +663,11 @@ jobs:
634663
if: ${{ inputs.bmotion }}
635664
uses: ./.github/workflows/bit.ci.Bmotion.yml
636665

666+
blex:
667+
name: blex
668+
if: ${{ inputs.blex }}
669+
uses: ./.github/workflows/bit.ci.Blex.yml
670+
637671
bonboarding:
638672
name: bonboarding
639673
if: ${{ inputs.bonboarding }}
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: bit platform CI - Blex E2E
2+
3+
# The cross-host suites: every web render mode in Chromium on net10.0/net9.0/net8.0, Blazor Hybrid in WebView2,
4+
# and trimmed/AOT publishes. They take far longer than the build-and-unit pipeline (bit.ci.Blex.yml), so they
5+
# run only when started by hand. See src/Blex/Tests/Bit.Blex.Tests.E2E/README.md for what each job proves and
6+
# how to run it locally.
7+
8+
on:
9+
workflow_dispatch:
10+
11+
env:
12+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
19+
# Every web render mode (static SSR, Server, WebAssembly, Auto, with and without prerendering) in
20+
# Chromium, on each runtime the library ships for.
21+
e2e-web:
22+
name: Blex E2E - web render modes (${{ matrix.framework }})
23+
runs-on: ubuntu-24.04
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
framework: [ net10.0, net9.0, net8.0 ]
28+
29+
steps:
30+
- name: Checkout source code
31+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32+
with:
33+
persist-credentials: false
34+
35+
- name: Setup .NET 10.0
36+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
37+
with:
38+
global-json-file: src/global.json
39+
40+
- name: Setup .NET 9.0
41+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
42+
with:
43+
dotnet-version: 9.0.x
44+
45+
- name: Setup .NET 8.0
46+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
47+
with:
48+
dotnet-version: 8.0.x
49+
50+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
51+
with:
52+
node-version: 24
53+
54+
- name: Build the web harness host
55+
run: dotnet build src/Blex/Tests/Bit.Blex.Tests.Harness.Web/Bit.Blex.Tests.Harness.Web.csproj -c Release -f ${{ matrix.framework }}
56+
57+
- name: Build the E2E suite
58+
run: dotnet build src/Blex/Tests/Bit.Blex.Tests.E2E/Bit.Blex.Tests.E2E.csproj -c Release
59+
60+
- name: Install Playwright Chromium
61+
run: pwsh src/Blex/Tests/Bit.Blex.Tests.E2E/bin/Release/net10.0/playwright.ps1 install --with-deps chromium
62+
63+
- name: Run E2E tests
64+
env:
65+
BLEX_E2E_FRAMEWORK: ${{ matrix.framework }}
66+
BLEX_E2E_CONFIGURATION: Release
67+
BLEX_E2E_SKIP_BUILD: 1
68+
# Run from inside src so src/global.json's Microsoft.Testing.Platform runner setting applies.
69+
run: >
70+
cd src/Blex/Tests/Bit.Blex.Tests.E2E &&
71+
dotnet test -c Release --no-build
72+
--filter "FullyQualifiedName!~HybridModeTests"
73+
--report-trx --report-trx-filename blex-e2e-web-${{ matrix.framework }}.trx
74+
75+
- name: Upload test results
76+
if: always()
77+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
78+
with:
79+
name: blex-e2e-web-${{ matrix.framework }}
80+
path: '**/blex-e2e-web-*.trx'
81+
if-no-files-found: ignore
82+
83+
# Blazor Hybrid: the harness in a WinForms BlazorWebView (the WebView core MAUI Blazor Hybrid uses),
84+
# driven through WebView2's DevTools port.
85+
e2e-hybrid:
86+
name: Blex E2E - Blazor Hybrid (WebView2)
87+
runs-on: windows-2025
88+
89+
steps:
90+
- name: Checkout source code
91+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
92+
with:
93+
persist-credentials: false
94+
95+
- name: Setup .NET 10.0
96+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
97+
with:
98+
global-json-file: src/global.json
99+
100+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
101+
with:
102+
node-version: 24
103+
104+
# windows-2025 ships the Edge browser but not the WebView2 Runtime, which BlazorWebView needs.
105+
- name: Install the WebView2 Runtime
106+
shell: pwsh
107+
run: |
108+
$clientKey = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}'
109+
$version = (Get-ItemProperty $clientKey -ErrorAction SilentlyContinue).pv
110+
if (-not $version -or $version -eq '0.0.0.0') {
111+
$installer = Join-Path $env:RUNNER_TEMP 'MicrosoftEdgeWebview2Setup.exe'
112+
Invoke-WebRequest 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' -OutFile $installer
113+
Start-Process $installer -ArgumentList '/silent', '/install' -Wait
114+
$version = (Get-ItemProperty $clientKey -ErrorAction SilentlyContinue).pv
115+
}
116+
if (-not $version -or $version -eq '0.0.0.0') { throw 'The WebView2 Runtime did not install.' }
117+
Write-Host "WebView2 Runtime $version"
118+
119+
- name: Build the hybrid harness host
120+
run: dotnet build src/Blex/Tests/Bit.Blex.Tests.Harness.Hybrid/Bit.Blex.Tests.Harness.Hybrid.csproj -c Release
121+
122+
- name: Build the E2E suite
123+
run: dotnet build src/Blex/Tests/Bit.Blex.Tests.E2E/Bit.Blex.Tests.E2E.csproj -c Release
124+
125+
# No Playwright browser download: it attaches to the WebView2 Runtime installed above.
126+
- name: Run hybrid E2E tests
127+
env:
128+
BLEX_E2E_CONFIGURATION: Release
129+
BLEX_E2E_SKIP_BUILD: 1
130+
run: >
131+
cd src/Blex/Tests/Bit.Blex.Tests.E2E &&
132+
dotnet test -c Release --no-build
133+
--filter "FullyQualifiedName~HybridModeTests"
134+
--report-trx --report-trx-filename blex-e2e-hybrid.trx
135+
136+
- name: Upload test results
137+
if: always()
138+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
139+
with:
140+
name: blex-e2e-hybrid
141+
path: '**/blex-e2e-hybrid.trx'
142+
if-no-files-found: ignore
143+
144+
# Publishes the harness the way a WebAssembly app ships - trimmed, and in a second leg AOT-compiled -
145+
# failing on any trim analysis warning raised inside Bit.Blex, then runs the browser suite against that
146+
# published output. Trimming is where reflection-based snapshots, the JS bridges' [JSInvokable] callbacks and
147+
# the prerender state handoff break, and none of it is visible in a Debug build.
148+
publish-gate:
149+
name: Blex publish gate (${{ matrix.name }})
150+
runs-on: ubuntu-24.04
151+
strategy:
152+
fail-fast: false
153+
matrix:
154+
include:
155+
- name: trimmed
156+
properties: ''
157+
- name: aot
158+
properties: '-p:RunAOTCompilation=true'
159+
160+
steps:
161+
- name: Checkout source code
162+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
163+
with:
164+
persist-credentials: false
165+
166+
- name: Setup .NET 10.0
167+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
168+
with:
169+
global-json-file: src/global.json
170+
171+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
172+
with:
173+
node-version: 24
174+
175+
- name: Install wasm-tools
176+
if: matrix.name == 'aot'
177+
run: dotnet workload install wasm-tools
178+
179+
- name: Publish the web harness host (fails on trim/AOT warnings from Bit.Blex)
180+
run: bash src/Blex/Tests/Bit.Blex.Tests.E2E/publish-gate.sh ${{ github.workspace }}/artifacts/harness-${{ matrix.name }} ${{ matrix.properties }}
181+
182+
- name: Build the E2E suite
183+
run: dotnet build src/Blex/Tests/Bit.Blex.Tests.E2E/Bit.Blex.Tests.E2E.csproj -c Release
184+
185+
- name: Install Playwright Chromium
186+
run: pwsh src/Blex/Tests/Bit.Blex.Tests.E2E/bin/Release/net10.0/playwright.ps1 install --with-deps chromium
187+
188+
- name: Run E2E tests against the published host
189+
env:
190+
BLEX_E2E_PUBLISHED_HOST: ${{ github.workspace }}/artifacts/harness-${{ matrix.name }}
191+
run: >
192+
cd src/Blex/Tests/Bit.Blex.Tests.E2E &&
193+
dotnet test -c Release --no-build
194+
--filter "FullyQualifiedName!~HybridModeTests"
195+
--report-trx --report-trx-filename blex-publish-${{ matrix.name }}.trx
196+
197+
- name: Upload test results
198+
if: always()
199+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
200+
with:
201+
name: blex-publish-${{ matrix.name }}
202+
path: '**/blex-publish-*.trx'
203+
if-no-files-found: ignore

‎.github/workflows/bit.ci.Blex.yml‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: bit platform CI - Blex
2+
3+
# Build, unit, source-generator and MCP tests, and a pack of every package. The browser, hybrid and publish-gate
4+
# suites live in bit.ci.Blex.e2e.yml and run on demand only.
5+
6+
on:
7+
workflow_dispatch:
8+
workflow_call:
9+
pull_request:
10+
paths:
11+
- 'src/Blex/**'
12+
13+
env:
14+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
21+
# Its `if:` skips the job on Release/Prerelease/Version PRs.
22+
build-Blex:
23+
if: startsWith(github.event.pull_request.title, 'Prerelease') != true && startsWith(github.event.pull_request.title, 'Release') != true && startsWith(github.event.pull_request.title, 'Version') != true
24+
name: build Bit.Blex
25+
runs-on: ubuntu-24.04
26+
27+
steps:
28+
29+
- name: Checkout source code
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
persist-credentials: false
33+
34+
- name: Setup .NET 10.0
35+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
36+
with:
37+
global-json-file: src/global.json
38+
39+
- name: Setup .NET 9.0
40+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
41+
with:
42+
dotnet-version: 9.0.x
43+
44+
- name: Setup .NET 8.0
45+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
46+
with:
47+
dotnet-version: 8.0.x
48+
49+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
50+
with:
51+
node-version: 24
52+
53+
- name: dotnet build
54+
run: dotnet build src/Blex/Bit.Blex.slnx
55+
56+
- name: dotnet test (runtime, Blazor, MAUI and generated code - net8.0/net9.0/net10.0)
57+
# Run from inside src so src/global.json's "test" runner setting applies
58+
# (from the repo root the SDK falls back to the unsupported VSTest path).
59+
run: cd src/Blex/Tests/Bit.Blex.Tests && dotnet test --no-build
60+
61+
- name: dotnet test (source generator)
62+
run: cd src/Blex/Tests/Bit.Blex.Tests.Generators && dotnet test --no-build
63+
64+
- name: dotnet test (MCP server)
65+
run: cd src/Blex/Tests/Bit.Blex.Tests.Mcp && dotnet test --no-build
66+
67+
# Packing on every run means a broken nuspec, a missing analyzer or a stale readme path is caught
68+
# here rather than at release time. Each project is built in Release with GeneratePackageOnBuild
69+
# off before it is packed, as all.ci.yml and nuget.org.yml do: Bit.Build.props turns that
70+
# property on for Release, and a bare `dotnet pack` of a multi-targeted project with it on fails
71+
# with NU5026 (the pack-on-build step runs before every TFM's assembly is on disk).
72+
- name: dotnet pack
73+
run: |
74+
for project in Bit.Blex Bit.Blex.Generators Bit.Blex.Blazor Bit.Blex.Maui Bit.Blex.Testing; do
75+
dotnet build src/Blex/$project/$project.csproj -c Release -p:GeneratePackageOnBuild=false -p:WarningLevel=0 -p:RunCodeAnalysis=false
76+
dotnet pack src/Blex/$project/$project.csproj --output ./packages --configuration Release
77+
done

0 commit comments

Comments
 (0)