-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: XmlPeek and XmlPoke tasks when optional parameter is not provided, throw unhandled exceptions #9140
Comments
If the choice is made to address this issue, I can provide the fix. |
Team triage: sounds like a bug to us. We would gladly take a fix for it, thanks! |
rainersigwald
pushed a commit
that referenced
this issue
Oct 4, 2023
Add `[Required]` to parameters. - `XmlPeek` Task - Change `Query` parameter. - Remove redundant `Dispose` that was flagged by the analyzer. - Change XmlPeek.XmlInput class from `Internal` to `private sealed` and change access of some members - Minor cleanup changes - `XmlPoke` Task - Change `Query` parameter. - Change `XmlInputPath` parameter. - Minor cleanup changes - XmlPeek_Tests class - Add new `PeekWithNoParameters` test - XmlPoke_Tests class - Remove `PokeMissingParams` test - The test was defined as a `[Fact]` and used a for loop to test 4 distinct cases - The test expected `ArgumentNullException` to be thrown - Add 4 new tests, one for each of the four cases: - `PokeWithNoParameters` - `PokeWithMissingRequiredQuery` - `PokeWithMissingRequiredXmlInputPath` - `PokeWithRequiredParameters` (completes the replacement of `PokeMissingParams` but might be a redundant test) Fixes #9140.
bulatgrzegorz
pushed a commit
to bulatgrzegorz/selective-condition-evaluator
that referenced
this issue
Oct 16, 2023
Add `[Required]` to parameters. - `XmlPeek` Task - Change `Query` parameter. - Remove redundant `Dispose` that was flagged by the analyzer. - Change XmlPeek.XmlInput class from `Internal` to `private sealed` and change access of some members - Minor cleanup changes - `XmlPoke` Task - Change `Query` parameter. - Change `XmlInputPath` parameter. - Minor cleanup changes - XmlPeek_Tests class - Add new `PeekWithNoParameters` test - XmlPoke_Tests class - Remove `PokeMissingParams` test - The test was defined as a `[Fact]` and used a for loop to test 4 distinct cases - The test expected `ArgumentNullException` to be thrown - Add 4 new tests, one for each of the four cases: - `PokeWithNoParameters` - `PokeWithMissingRequiredQuery` - `PokeWithMissingRequiredXmlInputPath` - `PokeWithRequiredParameters` (completes the replacement of `PokeMissingParams` but might be a redundant test) Fixes dotnet#9140.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue Description
XmlPeek
Query parameter
The
XmlPeek
task has an optionalQuery
parameter. When theQuery
parameter is not provided, the task will fail with an "unhandled exception" error.XmlPoke
Query parameter
The
XmlPoke
task also has an optionalQuery
parameter with the same "unhandled exception" issue.XmlInputPath parameter
Further the optional
XmlInputPath
parameter when not provided will also cause the task to fail with an "unhandled exception" error.Steps to Reproduce
Running MSBuild against each of the following three minimal projects will demonstrate each of the three issues.
XmlPeek - Query
XmlPoke - Query
XmlPoke - XmlInputPath
TestProjects.zip
Expected Behavior
Appropriate specific error messages should be reported.
The
Query
parameter for both tasks and theXmlInputPath
parameter for XmlPoke are de facto required parameters. If changed from optional to required, then error MSB4044 can be reported, e.g.Actual Behavior
The "This is an unhandled exception from a task ..." message is reported.
Analysis
The two tasks for the three parameters are calling
ErrorUtilities.VerifyThrowArgumentNull()
instead of reporting a more specific error message.A possible fix:
[Required]
to the parameters.RequiredPropertyNotSetError
message (MSB4044) when no value is provided.Versions & Configurations
macOS Monterey
MSBuild version 17.8.0-dev-23419-01+76a6ec27c for .NET
17.8.0.41901
Windows 11
MSBuild version 17.8.0-dev-23419-01+c5a28edd3 for .NET
17.8.0.41901
The text was updated successfully, but these errors were encountered: