Skip to content

Commit 34c2cbb

Browse files
committed
Implement GenerateAssemblyInfo template reintegration (Spec 002)
This change standardizes assembly metadata across all 101 managed projects by enforcing the CommonAssemblyInfoTemplate policy and restoring custom attributes lost during previous migrations. Key changes: - Added `scripts/GenerateAssemblyInfo/` automation suite: - `audit_generate_assembly_info.py`: Inventories project state (Template-only vs. Custom). - `convert_generate_assembly_info.py`: Links `Src/CommonAssemblyInfo.cs`, sets `<GenerateAssemblyInfo>false`, and restores missing `AssemblyInfo.cs` files from git history. - `validate_generate_assembly_info.py`: Enforces structural compliance and invokes MSBuild/Reflection checks. - `reflect_attributes.ps1`: Verifies assembly attributes (Company, Product, Copyright) in build output. - Updated `Directory.Build.props` to document the new AssemblyInfo policy and disable determinism for wildcard versioning. - Updated `.github/instructions/managed.instructions.md` with developer guidelines for the template. - Finalized `specs/002-convergence-generate-assembly-Implement GenerateAssemblyInfo template reintegration (Spec 002) This change standardizes assembly metadata across all 101 managed projects by enforcing the CommonAssemblyInfoTemplate policy and restoring custom attributes lost during previous migrations. Key changes: - Added `scripts/GenerateAssemblyInfo/` automation suite: - `audit_generate_assembly_info.py`: Inventories project state (Template-only vs. Custom). - `convert_generate_assembly_info.py`: Links `Src/CommonAssemblyInfo.cs`, sets `<GenerateAssemblyInfo>false`, and restores missing `AssemblyInfo.cs` files from git history. - `validate_generate_assembly_info.py`: Enforces structural compliance and invokes MSBuild/Reflection checks. - `reflect_attributes.ps1`: Verifies assembly attributes (Company, Product, Copyright) in build output. - Updated `Directory.Build.props` to document the new AssemblyInfo policy and disable determinism for wildcard versioning. - Updated `.github/instructions/managed.instructions.md` with developer guidelines for the template. - Finalized `specs/002-convergence-generate-assembly-
1 parent 1315780 commit 34c2cbb

File tree

220 files changed

+4001
-470
lines changed

Some content is hidden

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

220 files changed

+4001
-470
lines changed

.github/instructions/build.instructions.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,31 @@ dotnet restore FieldWorks.proj --packages packages/
185185
- **`Build/SetupInclude.targets`**: Environment setup; touch only when absolutely needed
186186
- **`Directory.Build.props`**: Shared properties for all projects; changes affect everyone
187187

188+
## Running Tests
189+
190+
### With MSBuild (current method)
191+
```powershell
192+
# Run all tests
193+
msbuild FieldWorks.proj /p:Configuration=Debug /p:Platform=x64 /p:action=test
194+
195+
# Run specific test target
196+
msbuild Build\FieldWorks.targets /t:CacheLightTests /p:Configuration=Debug /p:Platform=x64 /p:action=test
197+
```
198+
199+
Test results: `Output/Debug/<ProjectName>.dll-nunit-output.xml`
200+
201+
### With dotnet test (under development)
202+
```powershell
203+
# Future simplified approach
204+
dotnet test FieldWorks.sln --configuration Debug
205+
```
206+
207+
See `.github/instructions/testing.instructions.md` for detailed test execution guidance.
208+
188209
## References
189210
- **CI/CD**: `.github/workflows/` for CI steps
190211
- **Build Infrastructure**: `Build/` for targets/props and build infrastructure
191212
- **Traversal Project**: `FieldWorks.proj` for declarative build order
192213
- **Shared Properties**: `Directory.Build.props` for all projects
193214
- **Native Build**: `Build/mkall.targets` for C++ build orchestration
215+
- **Testing**: `.github/instructions/testing.instructions.md` for test execution

.github/instructions/managed.instructions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ This file describes conventions, deterministic requirements, and best practices
2323
## Key Rules
2424
- Use existing patterns for localization, unit tests, and avoid runtime-incompatible behaviors.
2525
- Keep public APIs stable and documented with XML docs.
26+
- **AssemblyInfo Policy**:
27+
- All managed projects must link `Src/CommonAssemblyInfo.cs` via `<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />`.
28+
- Set `<GenerateAssemblyInfo>false</GenerateAssemblyInfo>` to prevent SDK duplicate attribute errors.
29+
- Restore and maintain project-specific `AssemblyInfo*.cs` files if custom attributes are required.
30+
- Use `scripts/GenerateAssemblyInfo/validate_generate_assembly_info.py` to verify compliance.
2631

2732
## Test exclusion conversion playbook (Pattern A standard)
2833
- Always prefer explicit `<ProjectName>Tests/**` exclusions. For nested test folders add matching explicit entries (for example `Component/ComponentTests/**`).

.github/instructions/testing.instructions.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ Guidance for writing deterministic unit and integration tests for FieldWorks and
1010

1111
## Context loading
1212
- Locate tests near their components (e.g., `Src/<Component>.Tests`). Some integration scenarios use `TestLangProj/` data.
13-
- Determine test runner: SDK-style projects use `dotnet test`; .NET Framework often uses NUnit Console.
13+
- **Current test infrastructure**: MSBuild-based with NUnit Console Runner via `Build/FieldWorks.targets`
14+
- **Future direction**: Migrating to `dotnet test` (VSTest platform) for modern CI/CD integration
15+
- Test projects are marked with `<IsTestProject>true</IsTestProject>` and automatically receive modern test packages via `Directory.Build.props`
1416

1517
## Deterministic requirements
1618
- Keep tests hermetic: avoid external state; use test data under version control.
@@ -24,11 +26,59 @@ Guidance for writing deterministic unit and integration tests for FieldWorks and
2426
## Key Rules
2527
- Keep tests deterministic and fast where possible; add integration tests only for end-to-end scenarios.
2628
- Name tests clearly for reviewer understanding.
29+
- Tests use NUnit 3.x framework with `[Test]` and `[TestFixture]` attributes.
30+
31+
## Running Tests
32+
33+
### Current Method: MSBuild with `action=test` (Recommended for Now)
34+
35+
The established approach uses custom MSBuild tasks that invoke NUnit Console Runner:
2736

28-
## Examples
2937
```powershell
30-
# dotnet test --filter Category=Unit
38+
# Run all tests during build
39+
.\build.ps1 -Configuration Debug
40+
# Or explicitly:
41+
msbuild FieldWorks.proj /p:Configuration=Debug /p:Platform=x64 /p:action=test
42+
43+
# Run tests for a specific component
44+
msbuild Build\FieldWorks.targets /t:CacheLightTests /p:Configuration=Debug /p:Platform=x64 /p:action=test
45+
```
46+
47+
**How it works**:
48+
- Tests are executed via NUnit Console Runner: `packages/NUnit.ConsoleRunner.3.12.0/tools/nunit3-console.exe`
49+
- Test results: `Output/Debug/<ProjectName>.dll-nunit-output.xml`
50+
- Each test target in `Build/FieldWorks.targets` has an `NUnit3` task that runs when `action=test`
51+
52+
### Future Method: `dotnet test` (Under Development)
53+
54+
A modernized `dotnet test` workflow is planned:
55+
56+
```powershell
57+
# Target workflow (not fully functional yet):
58+
dotnet test FieldWorks.sln --configuration Debug
59+
60+
# Or specific projects:
61+
dotnet test Src/InstallValidator/InstallValidatorTests/InstallValidatorTests.csproj
62+
```
63+
64+
**Current Status**:
65+
- Test projects now reference `Microsoft.NET.Test.Sdk` and `NUnit3TestAdapter` via `Directory.Build.props`
66+
- Adapter discovery with .NET Framework 4.8 projects needs additional work
67+
- This approach will replace MSBuild-based test execution once fully validated
68+
69+
### In Docker Container
70+
71+
```powershell
72+
# Current working approach (MSBuild)
73+
docker run --rm -v "${PWD}:C:\src" -w C:\src fw-build:ltsc2022 `
74+
powershell -NoLogo -Command "msbuild FieldWorks.proj /p:Configuration=Debug /p:Platform=x64 /p:action=test"
75+
76+
# Future approach (dotnet test - when adapter discovery is fixed)
77+
docker run --rm -v "${PWD}:C:\src" -w C:\src fw-build:ltsc2022 `
78+
powershell -NoLogo -Command "C:\dotnet\dotnet.exe test FieldWorks.sln --configuration Debug"
3179
```
3280

3381
## References
34-
- Test data: `TestLangProj/`
82+
- **Build Infrastructure**: `Build/FieldWorks.targets` for MSBuild test tasks
83+
- **Test Data**: `TestLangProj/` for integration test data
84+
- **Build Instructions**: `.github/instructions/build.instructions.md` for build and test execution

Build/mkall.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@
734734
<Architecture Condition="'$(Platform)'=='x64'">64</Architecture>
735735
<Architecture Condition="'$(Platform)'!='x64'">32</Architecture>
736736
<GeckoDir Condition="'$(OS)'=='Windows_NT'"
737-
>$(PackagesDir)/Geckofx60.$(Architecture).60.0.54</GeckoDir
737+
>$(PackagesDir)/Geckofx60.$(Architecture).60.0.56</GeckoDir
738738
>
739739
</PropertyGroup>
740740
<ItemGroup>

Directory.Build.props

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
<Platforms Condition="'$(Platforms)' == ''">x64</Platforms>
99
<!-- Force 64-bit MSBuild host to avoid crashes loading 64-bit native DLLs in build tasks -->
1010
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
11+
<!-- Disable determinism to allow wildcard versions in CommonAssemblyInfo.cs -->
12+
<Deterministic>false</Deterministic>
13+
</PropertyGroup>
14+
<PropertyGroup Label="AssemblyInfo Policy">
15+
<!--
16+
CommonAssemblyInfoTemplate Policy:
17+
All managed projects must link Src/CommonAssemblyInfo.cs to ensure consistent versioning and metadata.
18+
When linking the template, disable SDK auto-generation to prevent CS0579 duplicate attribute errors.
19+
20+
Usage:
21+
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
22+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
23+
-->
1124
</PropertyGroup>
1225
<PropertyGroup Label="Shared Paths for Traversal Build">
1326
<!-- Root directory paths -->
@@ -42,4 +55,16 @@
4255
Nested test folders must also be explicitly excluded.
4356
-->
4457
</ItemGroup>
58+
<!-- Modern test infrastructure for all test projects -->
59+
<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
60+
<!-- For .NET Framework projects, ensure NuGet package assemblies are copied to output directory -->
61+
<!-- This is required for dotnet test to discover test adapters -->
62+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
63+
</PropertyGroup>
64+
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
65+
<!-- Microsoft.NET.Test.Sdk enables 'dotnet test' support (VSTest platform) -->
66+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
67+
<!-- NUnit3TestAdapter enables NUnit test discovery for VSTest -->
68+
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
69+
</ItemGroup>
4570
</Project>

Lib/src/ScrChecks/ScrChecksTests/ScrChecksTests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
</PropertyGroup>
2525
<ItemGroup>
2626
<PackageReference Include="NUnit" Version="4.4.0" />
27-
<PackageReference Include="NUnit3TestAdapter" Version="5.2.0" />
28-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
29-
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
27+
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="9.0.9" />
3028
<PackageReference Include="SIL.LCModel.Core" Version="11.0.0-*" />
3129
<PackageReference Include="SIL.LCModel.Core.Tests" Version="11.0.0-*" PrivateAssets="All" />
3230
<PackageReference Include="SIL.LCModel.Utils" Version="11.0.0-*" />

Post-Install-Setup.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ if (Test-Path $dotnetSdkPath) {
8282
$workloadLocator = Join-Path $msbuildSdkPath 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator\Sdk'
8383
if (-not (Test-Path $workloadLocator)) {
8484
New-Item -ItemType Directory -Path $workloadLocator -Force | Out-Null
85-
# Create empty Sdk.props and Sdk.targets
85+
# Create empty Sdk.props, Sdk.targets, and AutoImport.props
8686
Set-Content -Path (Join-Path $workloadLocator 'Sdk.props') -Value '<?xml version="1.0" encoding="utf-8"?><Project />'
8787
Set-Content -Path (Join-Path $workloadLocator 'Sdk.targets') -Value '<?xml version="1.0" encoding="utf-8"?><Project />'
88+
Set-Content -Path (Join-Path $workloadLocator 'AutoImport.props') -Value '<?xml version="1.0" encoding="utf-8"?><Project />'
8889
}
8990

9091
# Create stub for WorkloadManifestTargetsLocator (not present in .NET 8.0.100)

Src/AssemblyInfoForTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@
4343
// Allow creating COM objects from manifest file important that it comes after InitializeIcu
4444
[assembly: CreateComObjectsFromManifest]
4545

46-
// This is for testing VersionInfoProvider in FwUtils
47-
[assembly: AssemblyInformationalVersion("9.0.6 45470 Alpha")]
46+
// CommonAssemblyInfo.cs now provides the informational version for all assemblies.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;

Src/CacheLight/CacheLightTests/CacheLightTests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@
3838
<ProjectReference Include="../../Common/ViewsInterfaces/ViewsInterfaces.csproj" />
3939
<ProjectReference Include="../CacheLight.csproj" />
4040
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="..\..\CommonAssemblyInfo.cs">
43+
<Link>Properties\CommonAssemblyInfo.cs</Link>
44+
</Compile>
45+
</ItemGroup>
4146
</Project>

0 commit comments

Comments
 (0)