-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Background
See also:
Problem
Following these steps to test:
- Generate solution with
./tooling/GenerateSingleSolution.ps1 -c RichSuggestBox - When VS loads, navigate to folder components->RichSuggestBox->heads
- Unload RichSuggestBox.Wasm
- Right-click RichSuggestBox.Wasdk and select "Run Tests"
Results in this build error:
| Severity | Code | Description | Project | File | Line | Suppression State |
|---|---|---|---|---|---|---|
| Error (active) | CS0122 | 'RichSuggestBox.CommitSuggestionAsync(object)' is inaccessible due to its protection level | RichSuggestBox.Tests.Wasdk | V:\Windows\components\RichSuggestBox\tests\Test_RichSuggestBox.cs | 362 |
Solution
This seems to be happening because RichSuggestBox.CommitSuggestionAsync is marked internal, which means InternalsVisibleTo isn't working as expected for test projects.
Specifically, the single-component solution template uses the AssemblyName ProjectTemplateExperiment.Tests.WinAppSdk, which doesn't match values accepted by our single-component tests InternalsVisibleTo declaration, in the format $(ToolkitComponentName).Tests.WinAppSdk.
The single-component project template is still using Experiment in the AssemblyName and RootNamespace instead of just using the component name. Correcting this should fix the overall problem.
Tested: Following the repro steps again after these changes results in a successful build.
Assessment of related code
While doing this, it would be wise to check similar files for consistency:
- ProjectTemplate.Tests.Uwp.csproj has the same issue.
- ProjectTemplate.Uwp.csproj has the same issue.
- ProjectTemplate.Wasdk.csproj has the same issue.
- ProjectTemplate.Wasm.csproj does not have this problem, as neither this file nor our tooling define an
AssemblyNamethat can be used forInternalsVisibleTo.
These are simple enough to change, but the nature of the change-- updating the MSBuild definitions for RootNamespace and AssemblyName in the single-solution component template-- needs further consideration of the side-effects this change brings.
Full change evaluation
In total, what needs to change when RootNamespace and AssemblyName are updated in a test head like this?
- These changes are exclusive to highlighted single-component test heads, not to do with the gallery or our nuget packages.
- Since we're using shproj instead of csproj for unit tests:
- The root namespace is defined by the test head.
- The root namespace may differ from the namespace used in shared test projects.
- Tl;dr; namespaces can safely differ across shproj, but we should want consistency here.
- Anywhere we have "ComponentNameExperiment" rather than "ComponentName" is a leftover artifact from when we first created our tooling for Labs.
- Since we're aligning these for tests, we can align test code namespaces in the upstream repositories on tooling merge.
These changes will be submitted in a PR as prerequisite to the original ticket.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status