-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add the test verifying property functions used in dotnet console/webapp don't need a reflection #48475
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
+78
−0
Merged
Add the test verifying property functions used in dotnet console/webapp don't need a reflection #48475
Changes from all commits
Commits
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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,63 @@ | ||||||
// Licensed to the .NET Foundation under one or more agreements. | ||||||
// The .NET Foundation licenses this file to you under the MIT license. | ||||||
|
||||||
namespace Microsoft.NET.Build.Tests | ||||||
{ | ||||||
public class EvaluatorFastPathTests : SdkTest | ||||||
{ | ||||||
public EvaluatorFastPathTests(ITestOutputHelper log) : base(log) | ||||||
{ | ||||||
|
||||||
} | ||||||
|
||||||
[Fact] | ||||||
public void FastPathDoesNotNeedReflection() | ||||||
{ | ||||||
var testAsset = _testAssetsManager | ||||||
.CopyTestAsset("MSBuildBareBonesProject") | ||||||
.WithSource(); | ||||||
var command = new MSBuildCommand(testAsset, string.Empty); | ||||||
command | ||||||
.WithEnvironmentVariable("MSBuildLogPropertyFunctionsRequiringReflection", "true") | ||||||
.WithWorkingDirectory(testAsset.Path); | ||||||
command | ||||||
.ExecuteWithoutRestore() | ||||||
.Should() | ||||||
.Pass(); | ||||||
|
||||||
var logPath = Path.Combine(testAsset.Path, "PropertyFunctionsRequiringReflection"); | ||||||
File.Exists(logPath).Should().BeFalse(); | ||||||
} | ||||||
|
||||||
[Theory] | ||||||
[InlineData("console")] | ||||||
[InlineData("webapp")] | ||||||
public void EnsureDotnetCommonProjectPropertyFunctionsOnFastPath(string alias) | ||||||
{ | ||||||
var testDir = _testAssetsManager.CreateTestDirectory().Path; | ||||||
|
||||||
new DotnetNewCommand(Log, alias) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.WithoutCustomHive() | ||||||
.WithWorkingDirectory(testDir) | ||||||
.Execute() | ||||||
.Should() | ||||||
.Pass(); | ||||||
|
||||||
new DotnetBuildCommand(Log) | ||||||
.WithWorkingDirectory(testDir) | ||||||
.WithEnvironmentVariable("MSBuildLogPropertyFunctionsRequiringReflection", "true") | ||||||
.Execute() | ||||||
.Should() | ||||||
.Pass(); | ||||||
|
||||||
var logPath = Path.Combine(testDir, "PropertyFunctionsRequiringReflection"); | ||||||
// Functions from Microsoft.Build.Utilities.ToolLocationHelper are pending to add fast path, tracked by https://github.com/dotnet/msbuild/issues/10411. | ||||||
// This verification should be changed to no log file created once it is done. | ||||||
var toolLocationHelper_GetPlatformSDKLocation = "ReceiverType=Microsoft.Build.Utilities.ToolLocationHelper; ObjectInstanceType=; MethodName=GetPlatformSDKLocation(String, String)"; | ||||||
var toolLocationHelper_GetPlatformSDKDisplayName = "ReceiverType=Microsoft.Build.Utilities.ToolLocationHelper; ObjectInstanceType=; MethodName=GetPlatformSDKDisplayName(String, String)"; | ||||||
var lines = File.ReadAllLines(logPath); | ||||||
var allOnFastPathWithExceptions = lines.All(l => (toolLocationHelper_GetPlatformSDKLocation.Equals(l) || toolLocationHelper_GetPlatformSDKDisplayName.Equals(l))); | ||||||
allOnFastPathWithExceptions.Should().BeTrue(); | ||||||
} | ||||||
} | ||||||
} |
15 changes: 15 additions & 0 deletions
15
test/TestAssets/TestProjects/MSBuildBareBonesProject/BareBones.proj
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alias
is a keyword so let's avoid it as a name for variable