Add resource validation tests to prevent missing resource string errors#12611
Conversation
|
Hello @@copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
|
@copilot resolve the issue |
Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
Fixed in commit a7a17ea by adding the null-forgiving operator ( |
…oft.Build.Utilities.Core
|
The tests find the following referenced resource strings don't exist in the resource file. Microsoft.Build.Tasks.Core12 missing resource strings below only referenced in
Microsoft.Build.Utilities.Core1 resource string |
These . . . may never have been in the product? I can see the references added in MSBuild going back to dev10, but even in that old copy of the source I don't see a string. The question now is "is this code reachable and has just been broken for this long?" or "does this reveal unreachable code we can delete?"
Instead of duplicating it can we put it in |
|
Oh, i see what's going on with these resources in TaskGenerator |
@GangWang01 agreed with Rainer during standup that we can remove GenerateComments property and the code connected to it. Please do that. |
There was a problem hiding this comment.
Pull request overview
This PR adds resource validation tests to prevent runtime errors caused by code referencing missing resource strings. The changes address several historical issues where resources were missing or in the wrong assembly.
Changes:
- Adds comprehensive resource validation test infrastructure in
Resources_Tests.cswith regex-based extraction of resource references from source code - Moves the
Message.InvalidImportanceresource from Tasks assembly to Shared resources (where it should be accessible by ToolTask) - Removes unused
GenerateCommentsfunctionality from XamlTaskFactory - Adds a new test in ToolTask_Tests to verify invalid importance parameter handling
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Build.UnitTests/Resources_Tests.cs | New test infrastructure to validate all referenced resources exist in .resx files |
| src/Shared/Resources/Strings.shared.resx | Adds Message.InvalidImportance resource to shared resources |
| src/Shared/Resources/xlf/*.xlf | Updates localization files with new Message.InvalidImportance entry |
| src/Tasks/Resources/Strings.resx | Removes Message.InvalidImportance (moved to shared) with comment explaining the move |
| src/Tasks/Resources/xlf/*.xlf | Removes Message.InvalidImportance from localized resources |
| src/Tasks/XamlTaskFactory/TaskGenerator.cs | Removes unused GenerateComments property and related code generation logic |
| src/Utilities.UnitTests/ToolTask_Tests.cs | Adds test for invalid importance parameter and updates MyTool constructor to accept ResourceManager |
Summary
Successfully implemented resource validation tests to prevent issues where code references resource strings that don't exist in .resx files.
What was added:
src/Build.UnitTests/Resources_Tests.cs(275 lines)How it works:
Benefits:
Recent fix:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.