-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Сhange ProperyReassignment logged message type #9494
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
Merged
YuliiaKovalova
merged 5 commits into
dotnet:vs17.9
from
YuliiaKovalova:dev/ykovalova_fix_PropertyReassignment_message
Dec 11, 2023
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d7a35bf
change properyreassignment log message type
YuliiaKovalova eb2af2c
update tests after changing logger message
YuliiaKovalova 0f05a1f
fix comments to property reassignment test
YuliiaKovalova be5c974
fix review comments (add changewave 17.10)
YuliiaKovalova e4983c7
update test assertions
YuliiaKovalova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4597,7 +4597,7 @@ public void VerifyMSBuildLogsAMessageWhenLocalPropertyCannotOverrideValueOfGloba | |
| public void VerifyPropertyTrackingLoggingDefault() | ||
| { | ||
| // Having just environment variables defined should default to nothing being logged except one environment variable read. | ||
| this.VerifyPropertyTrackingLoggingScenario( | ||
| VerifyPropertyTrackingLoggingScenario( | ||
| null, | ||
| logger => | ||
| { | ||
|
|
@@ -4613,11 +4613,6 @@ public void VerifyPropertyTrackingLoggingDefault() | |
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
| .OfType<PropertyReassignmentEventArgs>() | ||
| .ShouldBeEmpty(); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
| .OfType<PropertyInitialValueSetEventArgs>() | ||
|
|
@@ -4628,7 +4623,7 @@ public void VerifyPropertyTrackingLoggingDefault() | |
| [Fact] | ||
| public void VerifyPropertyTrackingLoggingPropertyReassignment() | ||
| { | ||
| this.VerifyPropertyTrackingLoggingScenario( | ||
| VerifyPropertyTrackingLoggingScenario( | ||
| "1", | ||
| logger => | ||
| { | ||
|
|
@@ -4675,11 +4670,6 @@ public void VerifyPropertyTrackingLoggingNone() | |
| .EnvironmentVariableName | ||
| .ShouldBe("DEFINED_ENVIRONMENT_VARIABLE2"); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
| .OfType<PropertyReassignmentEventArgs>() | ||
| .ShouldBeEmpty(); | ||
|
|
||
| logger | ||
| .AllBuildEvents | ||
| .OfType<PropertyInitialValueSetEventArgs>() | ||
|
|
@@ -4919,6 +4909,57 @@ private void VerifyPropertyTrackingLoggingScenario(string envVarValue, Action<Mo | |
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Log when a property is being assigned a new value. | ||
| /// </summary> | ||
| [Fact] | ||
| public void VerifyLogPropertyReassignment() | ||
| { | ||
| string testtargets = ObjectModelHelpers.CleanupFileContents(@" | ||
|
||
| <Project xmlns='msbuildnamespace'> | ||
| <PropertyGroup> | ||
| <Prop>OldValue</Prop> | ||
| <Prop>NewValue</Prop> | ||
| </PropertyGroup> | ||
| <Target Name=""Test""/> | ||
| </Project>"); | ||
|
|
||
| string tempPath = Path.GetTempPath(); | ||
| string targetDirectory = Path.Combine(tempPath, "LogPropertyAssignments"); | ||
| string testTargetPath = Path.Combine(targetDirectory, "test.proj"); | ||
YuliiaKovalova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| try | ||
| { | ||
| Directory.CreateDirectory(targetDirectory); | ||
| File.WriteAllText(testTargetPath, testtargets); | ||
|
|
||
| MockLogger logger = new() | ||
| { | ||
| Verbosity = LoggerVerbosity.Diagnostic, | ||
| }; | ||
| ProjectCollection pc = new(); | ||
| pc.RegisterLogger(logger); | ||
| Project project = pc.LoadProject(testTargetPath); | ||
|
|
||
| bool result = project.Build(); | ||
| result.ShouldBeTrue(); | ||
| logger.BuildMessageEvents | ||
| .OfType<PropertyReassignmentEventArgs>() | ||
| .ShouldContain(r => r.PropertyName == "Prop" | ||
| && r.PreviousValue == "OldValue" | ||
| && r.NewValue == "NewValue" | ||
| && r.Message.StartsWith("Property reassignment: $(Prop)=\"NewValue\" (previous value: \"OldValue\")")); | ||
YuliiaKovalova marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| logger.BuildMessageEvents.ShouldBeOfTypes(new[] { typeof(PropertyReassignmentEventArgs) }); | ||
| } | ||
| finally | ||
| { | ||
| if (Directory.Exists(targetDirectory)) | ||
| { | ||
| FileUtilities.DeleteWithoutTrailingBackslash(targetDirectory, true /* recursive delete */); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #if FEATURE_HTTP_LISTENER | ||
| /// <summary> | ||
| /// HTTP server code running on a separate thread that expects a connection request | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.