Merge remote-tracking branch 'upstream/vs17.5'

This commit is contained in:
Rainer Sigwald 2023-03-28 11:19:30 -05:00
Родитель 698aac491a e7de133072
Коммит cb58a18c1f
1918 изменённых файлов: 22649 добавлений и 18636 удалений

Просмотреть файл

@ -157,13 +157,16 @@ csharp_space_between_square_brackets = false
dotnet_code_quality.ca1802.api_surface = private, internal
dotnet_code_quality.ca2208.api_surface = public
# CA1852: Seal internal types
dotnet_diagnostic.ca1852.severity = warning
# RS0037: Enable tracking of nullability of reference types in the declared API
# Our API is not annotated but new classes get nullable enabled so disable this.
# We'd be happy if everything was annotated and this could be removed.
dotnet_diagnostic.RS0037.severity = none
# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\n
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
# C++ Files
[*.{cpp,h,in}]
@ -200,5 +203,192 @@ end_of_line = lf
end_of_line = crlf
[src/**/*.{cs,vb}]
# Code style checks
dotnet_analyzer_diagnostic.category-Style.severity = warning
# Cast is redundant
dotnet_diagnostic.IDE0004.severity = suggestion
# IDE0005: Remove unnecessary usings/imports
dotnet_diagnostic.IDE0005.severity = warning
# Use explicit type instead of 'var'
dotnet_diagnostic.IDE0008.severity = suggestion
# Populate switch
dotnet_diagnostic.IDE0010.severity = suggestion
# Null check can be simplified
dotnet_diagnostic.IDE0016.severity = suggestion
# Object initialization can be simplified
dotnet_diagnostic.IDE0017.severity = suggestion
# Variable declaration can be inlined
dotnet_diagnostic.IDE0018.severity = suggestion
# Use pattern matching
dotnet_diagnostic.IDE0019.severity = suggestion
dotnet_diagnostic.IDE0020.severity = suggestion
# Use expression body for constructor
dotnet_diagnostic.IDE0021.severity = suggestion
# Use expression body for method
dotnet_diagnostic.IDE0022.severity = suggestion
# Use expression body for conversion operator
dotnet_diagnostic.IDE0023.severity = suggestion
# Use block body for operator
dotnet_diagnostic.IDE0024.severity = suggestion
# Use expression body for property
dotnet_diagnostic.IDE0025.severity = suggestion
# Use expression body for indexer
dotnet_diagnostic.IDE0026.severity = suggestion
# Use expression body for accessor
dotnet_diagnostic.IDE0027.severity = suggestion
# Collection initialization can be simplified
dotnet_diagnostic.IDE0028.severity = suggestion
# Null check can be simplified
dotnet_diagnostic.IDE0031.severity = suggestion
# Use auto property
dotnet_diagnostic.IDE0032.severity = suggestion
# 'default' expression can be simplified
dotnet_diagnostic.IDE0034.severity = suggestion
# Member name can be simplified
dotnet_diagnostic.IDE0037.severity = suggestion
# Use local function
dotnet_diagnostic.IDE0039.severity = suggestion
# Null check can be simplified
dotnet_diagnostic.IDE0041.severity = suggestion
# Variable declaration can be deconstructed
dotnet_diagnostic.IDE0042.severity = suggestion
# Made field readonly
dotnet_diagnostic.IDE0044.severity = suggestion
# 'if' statement can be simplified
dotnet_diagnostic.IDE0045.severity = suggestion
dotnet_diagnostic.IDE0046.severity = suggestion
# Parentheses can be removed
dotnet_diagnostic.IDE0047.severity = suggestion
# Parentheses should be added for clarity
dotnet_diagnostic.IDE0048.severity = suggestion
# Member name can be simplified
dotnet_diagnostic.IDE0049.severity = suggestion
# Use compound assignment
dotnet_diagnostic.IDE0054.severity = suggestion
# Indexing can be simplified
dotnet_diagnostic.IDE0056.severity = suggestion
# Slice can be simplified
dotnet_diagnostic.IDE0057.severity = suggestion
# Expression value is never used
dotnet_diagnostic.IDE0058.severity = suggestion
# Unnecessary assignment of a value
dotnet_diagnostic.IDE0059.severity = suggestion
# Remove unused parameter
dotnet_diagnostic.IDE0060.severity = suggestion
# Use expression body for a local function
dotnet_diagnostic.IDE0061.severity = suggestion
# Local function can be made static
dotnet_diagnostic.IDE0062.severity = suggestion
# Using directives must be placed outside of a namespace declaration
dotnet_diagnostic.IDE0065.severity = suggestion
# Use 'switch' expression
dotnet_diagnostic.IDE0066.severity = suggestion
# 'GetHashCode' implementation can be simplified
dotnet_diagnostic.IDE0070.severity = suggestion
# Interpolation can be simplified
dotnet_diagnostic.IDE0071.severity = suggestion
# Populate switch
dotnet_diagnostic.IDE0072.severity = suggestion
# Use compound assignment
dotnet_diagnostic.IDE0074.severity = suggestion
# Conditional expression can be simplified
dotnet_diagnostic.IDE0075.severity = suggestion
# Use pattern matching
dotnet_diagnostic.IDE0078.severity = suggestion
dotnet_diagnostic.IDE0083.severity = suggestion
# 'typeof' can be converted to 'nameof'
dotnet_diagnostic.IDE0082.severity = suggestion
# 'new' expression can be simplified
dotnet_diagnostic.IDE0090.severity = suggestion
# Simplify LINQ expression
dotnet_diagnostic.IDE0120.severity = suggestion
# namespace does not match folder structure
dotnet_diagnostic.IDE0130.severity = suggestion
# Null check can be clarified
dotnet_diagnostic.IDE0150.severity = suggestion
# Convert to block scoped namespaces
dotnet_diagnostic.IDE0160.severity = suggestion
# Simplify property pattern
dotnet_diagnostic.IDE0170.severity = suggestion
# Use tuple to swap values
dotnet_diagnostic.IDE0180.severity = suggestion
# Use tuple to swap values
dotnet_diagnostic.IDE0180.severity = suggestion
# Lambda expression can be removed
dotnet_diagnostic.IDE0200.severity = suggestion
# Convert to top-level statements
dotnet_diagnostic.IDE0210.severity = suggestion
# 'foreach' statement implicitly converts
dotnet_diagnostic.IDE0220.severity = suggestion
# Use UTF-8 string literal
dotnet_diagnostic.IDE0230.severity = suggestion
# Nullable directives
dotnet_diagnostic.IDE0240.severity = suggestion
dotnet_diagnostic.IDE0241.severity = suggestion
# Struct can be made 'readonly'
dotnet_diagnostic.IDE0250.severity = suggestion
# Null check can be simplified
dotnet_diagnostic.IDE0270.severity = suggestion
# naming rule violation
dotnet_diagnostic.IDE1006.severity = suggestion

54
.github/ISSUE_TEMPLATE/01_bugreport.md поставляемый
Просмотреть файл

@ -1,54 +0,0 @@
---
name: 🐞 Bug Report
about: Report a bug to help us improve MSBuild.
title: ''
labels: bug, needs-triage
---
<!-- This is a template that helps us provide quicker feedback. Please use any relevant sections and delete anything you don't need. -->
### Issue Description
<!--
* Please include a clear and concise description of the problem.
-->
### Steps to Reproduce
<!--
* Include as much of the following as possible:
* A minimal sample project that reproduces the issue.
* Your zipped project.
* IDE / CLI steps to create the project and reproduce the behaviour.
* Your command line invocation
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
[Details on sharing binary logs](https://aka.ms/msbuild/binlog)
[More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
-->
### Expected Behavior
<!--
* The expected output or behavior.
-->
### Actual Behavior
<!--
* The actual output or behavior.
-->
### Analysis
<!--
* If you have an idea where the problem might lie, let us know that here.
* Please include any pointers to code, relevant changes, or related issues you know of.
-->
### Versions & Configurations
<!--
* In a Visual Studio developer command prompt, run `msbuild -version` and paste the output here.
* If applicable, include the version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
* Post any other relevant configuration settings here.
* OS, architecture, etc.
-->

52
.github/ISSUE_TEMPLATE/01_bugreport.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,52 @@
name: 🐞 Bug Report
description: Report a bug to help us improve MSBuild.
title: "[Bug]: "
labels: ["bug", "needs-triage"]
body:
- type: textarea
attributes:
label: Issue Description
description: Please include a clear and concise description of the problem.
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
Include as much of the following as possible:
* a minimal sample project that reproduces the issue,
* your zipped project,
* IDE / CLI steps to create the project and reproduce the behaviour,
* your command line invocation.
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
* [Details on sharing binary logs](https://aka.ms/msbuild/binlog)
* [More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: The expected output or behavior.
validations:
required: true
- type: textarea
attributes:
label: Actual Behavior
description: The actual output or behavior.
validations:
required: true
- type: textarea
attributes:
label: Analysis
description: If you have an idea where the problem might lie, let us know that here. Please include any pointers to code, relevant changes, or related issues you know of.
- type: textarea
attributes:
label: Versions & Configurations
description: |
In a Visual Studio developer command prompt, run `msbuild -version` and paste the output here.
If applicable, include the version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc).
Post any other relevant configuration settings here: OS, architecture, etc.

65
.github/ISSUE_TEMPLATE/02_performanceissue.md поставляемый
Просмотреть файл

@ -1,65 +0,0 @@
---
name: 📉 Performance Issue
about: Report a performance issue or regression.
title: ''
labels: performance, needs-triage
---
<!-- This is a template that helps us provide quicker feedback. Please use any relevant sections and delete anything you don't need. -->
### Issue Description
<!--
* Please include a clear and concise description of the problem.
-->
### Steps to Reproduce
<!--
Include as much of the following if possible:
* A minimal sample project that reproduces the issue.
* Your zipped project.
* IDE / CLI steps to create the project and reproduce the behaviour.
* Your command line invocation
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
[Details on sharing binary logs](https://aka.ms/msbuild/binlog)
[More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
-->
### Data
<!--
* Please include all information you've gathered about this performance issue. This includes:
- Timing
- Measurements
- ETW Traces
- Call stacks
- Dumps
- etc.
* If possible please include text as text rather than images (so it shows up in searches).
* If applicable please include before and after measurements.
-->
### Analysis
<!--
* If you have an idea where the problem might lie, let us know that here.
* Please include any pointers to code, relevant changes, or related issues you know of.
-->
### Versions & Configurations
<!--
* In a Visual Studio developer command prompt, run `msbuild -version` and paste the output here.
* If applicable, include the version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):
Post any other relevant configuration settings here.
* OS, architecture, etc.
-->
### Regression?
<!--
* Is this a regression from a previous build/release?
* Please provide details on:
* What version of MSBuild or VS were you using before the regression?
* What version of MSBuild or VS are you on now that you discovered the regression?
-->

67
.github/ISSUE_TEMPLATE/02_performanceissue.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,67 @@
name: 📉 Performance Issue
description: Report a performance issue or regression.
title: "[Performance]: "
labels: ["performance", "needs-triage"]
body:
- type: textarea
attributes:
label: Issue Description
description: Please include a clear and concise description of the problem.
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
Include as much of the following as possible:
* a minimal sample project that reproduces the issue,
* your zipped project,
* IDE / CLI steps to create the project and reproduce the behaviour,
* your command line invocation.
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
* [Details on sharing binary logs](https://aka.ms/msbuild/binlog)
* [More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
validations:
required: true
- type: textarea
attributes:
label: Data
description: |
Please include all information you've gathered about this performance issue. This includes:
- Timing
- Measurements
- ETW Traces
- Call stacks
- Dumps
- etc.
If possible please include text as text rather than images (so it shows up in searches).
If applicable please include before and after measurements.
validations:
required: true
- type: textarea
attributes:
label: Analysis
description: If you have an idea where the problem might lie, let us know that here. Please include any pointers to code, relevant changes, or related issues you know of.
- type: textarea
attributes:
label: Versions & Configurations
description: |
In a Visual Studio developer command prompt, run `msbuild -version` and paste the output here.
If applicable, include the version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc).
Post any other relevant configuration settings here: OS, architecture, etc.
- type: checkboxes
attributes:
label: Regression
description: Is this a regression from a previous build/release?
options:
- label: "yes"
- label: "no"
- type: textarea
attributes:
label: Regression Details
description: |
Please provide details on regression: what version of MSBuild or VS were you using before the regression?

53
.github/ISSUE_TEMPLATE/03_mybuildisbroken.md поставляемый
Просмотреть файл

@ -1,53 +0,0 @@
---
name: 😵 My Build is Broken
about: Use this template for helping figure out what's wrong with your build.
title: ''
labels: needs-triage
---
<!-- NOTE: The MSBuild team receives a lot of issues and we need to prioritize them accordingly. Please understand that we may not get to your issue for some time. -->
<!-- This is a template that helps us provide quicker feedback. Please use any relevant sections and delete anything you don't need. -->
<!--
* Here are some useful links to help you figure out what's wrong.
* Our wiki: https://github.com/microsoft/msbuild/blob/master/documentation/wiki/Home.md
* General Help: https://github.com/microsoft/msbuild/blob/master/documentation/wiki/Something's-wrong-in-my-build.md
* Tips & Tricks: https://github.com/microsoft/msbuild/blob/master/documentation/wiki/MSBuild-Tips-%26-Tricks.md
-->
### Issue Description
<!--
* Please include a clear and concise description of the problem.
-->
### Steps to Reproduce
<!--
* Include as much of the following if possible:
* A minimal sample project that reproduces the issue.
* Your zipped project.
* IDE / CLI steps to create the project and reproduce the behaviour.
* Your command line invocation
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
[Details on sharing binary logs](https://aka.ms/msbuild/binlog)
[More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
-->
### Expected Behavior
<!--
* Include what you are trying to do, and the expected output or behavior.
-->
### Actual Behavior
<!--
* Include the actual output or behavior.
-->
### Ask us questions
<!--
* We ask that you first browse the above links, as your question may already have been answered.
* Be as detailed as you can with these questions.
-->

53
.github/ISSUE_TEMPLATE/03_mybuildisbroken.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,53 @@
name: 😵 My Build is Broken
description: Use this template for helping figure out what's wrong with your build.
title: "[Broken Build]: "
labels: ["needs-triage"]
body:
- type: markdown
attributes:
value: |
NOTE: The MSBuild team receives a lot of issues and we need to prioritize them accordingly. Please understand that we may not get to your issue for some time.
Here are some useful links to help you figure out what's wrong.
* [Our documentation](https://github.com/dotnet/msbuild/blob/main/documentation)
* [General Help](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Something's-wrong-in-my-build.md)
* [Tips & Tricks](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/MSBuild-Tips-%26-Tricks.md)
- type: textarea
attributes:
label: Issue Description
description: Please include a clear and concise description of the problem.
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
Include as much of the following as possible:
* a minimal sample project that reproduces the issue,
* your zipped project,
* IDE / CLI steps to create the project and reproduce the behaviour,
* your command line invocation.
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
* [Details on sharing binary logs](https://aka.ms/msbuild/binlog)
* [More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: The expected output or behavior.
validations:
required: true
- type: textarea
attributes:
label: Actual Behavior
description: The actual output or behavior.
validations:
required: true
- type: textarea
attributes:
label: Ask us questions
description: We ask that you first browse the above links, as your question may already have been answered. Be as detailed as you can with these questions.

6
.github/ISSUE_TEMPLATE/04_blankissue.md поставляемый
Просмотреть файл

@ -1,6 +0,0 @@
---
name: 📄 Blank Issue
about: Doesn't fit the other categories? File a blank ticket here.
title: ''
labels: needs-triage
---

Просмотреть файл

@ -1,34 +0,0 @@
---
name: 😱 Unhandled Exception
about: Reporting holes in our bug reporting system
title: ''
labels: bug
---
<!-- This is a template that helps us provide quicker feedback.
Use any relevant sections and delete what you don't need. -->
### Issue Description
<!--
Include a stack trace if possible.
If you do not see one, try looking in your temp folder for the most recently created file named
MSBuild_pid-{pid}_{guid}.failure.txt
-->
### Steps to Reproduce
<!--
* Include as many of these as possible:
* A minimal sample project that reproduces the issue
* IDE or CLI steps that create the project and reproduce the issue
* Your command line invocation
-->
### Analysis
<!-- If you think you know what the problem is, please include that here. -->
### System Configuration
<!--
What version of MSBuild are you using? (`msbuild --version` from a developer command prompt)
What version of the tool invoking MSBuild are you using? (`dotnet --version`, accessing it from the Visual Studio Installer, etc.)
OS version (or at least Windows/Mac/Linux), architecture, etc.
-->

47
.github/ISSUE_TEMPLATE/05_unhandledexception.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,47 @@
name: 😱 Unhandled Exception
description: Reporting holes in our bug reporting system
title: "[Unhandled Exception]: "
labels: ["bug", "needs-triage"]
body:
- type: textarea
attributes:
label: Issue Description
description: Please include a clear and concise description of the problem.
validations:
required: true
- type: textarea
attributes:
label: Steps to Reproduce
description: |
Include as much of the following as possible:
* a minimal sample project that reproduces the issue,
* your zipped project,
* IDE / CLI steps to create the project and reproduce the behaviour,
* your command line invocation.
If providing steps to reproduce the issue proves difficult, consider attaching a binlog:
* [Details on sharing binary logs](https://aka.ms/msbuild/binlog)
* [More information on binary logs](https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md)
NOTE: Binary logs capture environment information. Ensure it does not include any information you don't want to be public before you attach one.
If you want to share one just with Microsoft, you can [report a problem through Visual Studio](https://developercommunity.visualstudio.com/report) and share it privately with Microsoft.
validations:
required: true
- type: textarea
attributes:
label: Actual Behavior
description: |
The actual output or behavior. Include a stack trace if possible. If you do not see one, try looking in your temp folder for the most recently created file named `MSBuild_pid-{pid}_{guid}.failure.txt`
validations:
required: true
- type: textarea
attributes:
label: Analysis
description: If you have an idea where the problem might lie, let us know that here. Please include any pointers to code, relevant changes, or related issues you know of.
- type: textarea
attributes:
label: Versions & Configurations
description: |
In a Visual Studio developer command prompt, run `msbuild -version` and paste the output here.
If applicable, include the version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc).
Post any other relevant configuration settings here: OS, architecture, etc.

2
.github/ISSUE_TEMPLATE/config.yml поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: Issue with .NET (Core) SDK
url: https://github.com/dotnet/sdk/issues/new/choose

36
.github/fabricbot.json поставляемый
Просмотреть файл

@ -444,7 +444,41 @@
}
]
}
},
{
"taskType": "trigger",
"capabilityId": "IssueResponder",
"subCapability": "PullRequestResponder",
"version": "1.0",
"config": {
"conditions": {
"operator": "and",
"operands": [
{
"name": "prTargetsBranch",
"parameters": {
"branchName": "vs17.4"
}
}
]
},
"eventType": "pull_request",
"eventNames": [
"pull_request",
"issues",
"project_card"
],
"taskName": "Comment on vs* branches",
"actions": [
{
"name": "addReply",
"parameters": {
"comment": "Hello! I noticed that you're targeting one of our servicing branches. Please consider updating the version."
}
}
]
}
}
],
"userGroups": []
}
}

19
.github/workflows/backport.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,19 @@
name: Backport PR to branch
on:
issue_comment:
types: [created]
permissions:
contents: write
issues: write
pull-requests: write
actions: write
jobs:
backport:
uses: dotnet/arcade/.github/workflows/backport-base.yml@main
with:
pr_description_template: |
Backport of #%source_pr_number% to %target_branch%
/cc %cc_users%

3
.gitignore поставляемый
Просмотреть файл

@ -215,3 +215,6 @@ stage1/
# ETL traces
*.etl.zip
# .DS_Store for macOS
**/.DS_Store

Просмотреть файл

@ -23,9 +23,12 @@ variables:
- name: SourceBranch
value: $(IbcSourceBranchName)
# If we're not on a vs* branch, use main as our optprof collection branch
# NOTE: the code is temporarily fixed. For the branches that should use opt-prof from the main branch we should use the latest working Opt-Prof collected from main 20230217.4.
- ${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/heads/vs')) }}:
- name: OptProfDrop
value: 'OptimizationData/DotNet-msbuild-Trusted/main/20230217.4/7352286/1'
- name: SourceBranch
value: main
value: ''
# if OptProfDropName is set as a parameter, set OptProfDrop to the parameter and unset SourceBranch
- ${{ if ne(parameters.OptProfDropName, 'default') }}:
- name: OptProfDrop

Просмотреть файл

@ -14,8 +14,8 @@
<PropertyGroup>
<FullFrameworkTFM>net472</FullFrameworkTFM>
<!--
<!--
When updating the version of .NET Core for MSBuild, this property is the 'source of truth'.
Other locations to update the version number:
global.json
@ -43,8 +43,10 @@
<PropertyGroup>
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
<!-- NU1603: Microsoft.xunit.netcore.extensions package has dependencies to versions which aren't published, so ignore those warnings
NU5105: we're explicitly opting in to semver2, as is most of .NET Core
<!--
NU1507: ManagePackageVersionsCentrally implies source mapping, which we should consider turning on but it's nontrivial
NU1603: Microsoft.xunit.netcore.extensions package has dependencies to versions which aren't published, so ignore those warnings
NU5105: we're explicitly opting in to semver2, as is most of .NET Core
CS1701 and CS1702 are by default ignored by Microsoft.NET.Sdk, but if you define the NoWarn property in Directory.Build.props,
you don't get those defaults.
SYSLIB0011: Removing binary formatter will happen as part of a larger .NET-wide effort.
@ -52,7 +54,7 @@
RS0016 & RS0017: Roslyn analyzers seem to be bugged, claiming that API's that exist don't and vise-versa: https://github.com/dotnet/msbuild/issues/7903
-->
<NoWarn>$(NoWarn);NU1603;NU5105;1701;1702;SYSLIB0011;SYSLIB0037;SYSLIB0044;RS0016;RS0017;</NoWarn>
<NoWarn>$(NoWarn);NU1507;NU1603;NU5105;1701;1702;SYSLIB0011;SYSLIB0037;SYSLIB0044;RS0016;RS0017;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug-MONO'">
@ -84,11 +86,17 @@
<DefaultItemExcludes>$(DefaultItemExcludes);*.binlog</DefaultItemExcludes>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<DirectoryPackagesPropsPath>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'eng', 'Packages.props'))</DirectoryPackagesPropsPath>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
</PropertyGroup>
<!-- Enable SDK supplied netanalyzers for all target frameworks -->
<PropertyGroup>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
</Project>

Просмотреть файл

@ -24,10 +24,6 @@
<EditorConfigFiles Include="$(MSBuildThisFileDirectory)eng/Common.Test.globalconfig" />
</ItemGroup>
<PropertyGroup>
<CentralPackagesFile>$(MSBuildThisFileDirectory)eng/Packages.props</CentralPackagesFile>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.Build.CentralPackageVersions" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<Target Name="DeleteDevPackage" AfterTargets="GenerateNuspec">

Просмотреть файл

@ -1,24 +0,0 @@
# Getting Started
* [What is MSBuild?](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild)
* Building Testing and Debugging
* [Full Framework MSBuild](wiki/Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md)
* [.Net Core MSBuild](wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md)
* [Mono MSBuild](wiki/Building-Testing-and-Debugging-on-Mono-MSBuild.md)
# Resources
* [MSBuild Resources](wiki/MSBuild-Resources.md)
* [Contributed documentation](Contributions/README.md)
* [MSBuild Tips & Tricks](wiki/MSBuild-Tips-&-Tricks.md)
* [Binary log](wiki/Binary-Log.md)
* [Providing Binary Logs for investigation](wiki/Providing-Binary-Logs.md)
* [Contributing Code](wiki/Contributing-Code.md)
* [Target Maps](wiki/Target-Maps.md)
* Tasks
* [ResolveAssemblyReference](wiki/ResolveAssemblyReference.md)
* Problems?
* [Rebuilding when nothing changed](wiki/Rebuilding-when-nothing-changed.md)
* [Something's wrong in my build](wiki/Something's-wrong-in-my-build.md)
* [Microsoft.Build.Framework](wiki/Microsoft.Build.Framework.md)
* Some gotchas around the Microsoft.Build.Framework project/assembly.

87
documentation/README.md Normal file
Просмотреть файл

@ -0,0 +1,87 @@
Welcome to MSBuild docs!
The folder contains collection of docs and references for MSBuild, detailed information on how to work with this repo, and covers in-depth technical topics related to implementation.
## Getting Started
* [What is MSBuild?](https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild)
* Building Testing and Debugging
* [Full Framework MSBuild](wiki/Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md)
* [.Net Core MSBuild](wiki/Building-Testing-and-Debugging-on-.Net-Core-MSBuild.md)
* [macOS](wiki/Mac-Debugging.md)
* [MSBuild resources](wiki/MSBuild-Resources.md)
* [MSBuild tips & tricks](wiki/MSBuild-Tips-&-Tricks.md)
## NuGet packages
* [General information](consuming-nuget-package.md)
## Release information
* [Changelog](Changelog.md)
* [Release process](release.md)
* [Change waves](wiki/ChangeWaves.md)
* [Interactions with the internal repository](wiki/Interactions-with-the-internal-repository.md)
## Development and contributing
* [Providing binary logs for investigation](wiki/Providing-Binary-Logs.md)
* [Contributing code](wiki/Contributing-Code.md)
* [Contributing tasks](wiki/Contributing-Tasks.md)
* [Error codes](assigning-msb-error-code.md)
* [Deploying built MSBuild](Deploy-MSBuild.md)
* [Events emitted by MSBuild](specs/event-source.md)
* [Change waves (for developers)](wiki/ChangeWaves-Dev.md)
* [GitHub labels](wiki/Labels.md)
* [Localization](wiki/Localization.md)
### Problems?
* [Rebuilding when nothing changed](wiki/Rebuilding-when-nothing-changed.md)
* [Something's wrong in my build](wiki/Something's-wrong-in-my-build.md)
* [Some gotchas around the Microsoft.Build.Framework project/assembly](wiki/Microsoft.Build.Framework.md)
* [GAC and MSBuild](wiki/UnGAC.md)
* [When globbing returns original filespec](WhenGlobbingReturnsOriginalFilespec.md)
## In-depth tech topics
* [Reserved and built-in properties](Built-in-Propeties.md)
* [`ProjectReference`](ProjectReference-Protocol.md)
* [MSBuild Server](MSBuild-Server.md)
* [Low priority nodes](specs/low-priority-switch.md)
* [Project cache plugin](specs/project-cache.md)
* [Support for remote host objects](specs/remote-host-object.md)
* [Static graph](specs/static-graph.md)
* [Single project isolated builds: implementation details](specs/single-project-isolated-builds.md)
* [Task isolation](specs/task-isolation-and-dependencies.md)
* [Threading in MSBuild worker nodes](specs/threading.md)
* [Target maps](wiki/Target-Maps.md)
* [Managing parallelism in MSBuild](specs/resource-management.md)
* [SDK resolution](specs/sdk-resolvers-algorithm.md)
* [Nodes orchestration](wiki/Nodes-Orchestration.md)
### Tasks
* [`ResolveAssemblyReference`](wiki/ResolveAssemblyReference.md)
### Evaluation
* [Evaluation profiling](evaluation-profiling.md)
### Logging
* [Binary log](wiki/Binary-Log.md)
* [Live logger: how to opt in](livelogger/Opt-In-Mechanism.md)
## Designs
* [Resolve Assembly Reference as a service](design/rar-as-service.md)
* Prototype: https://github.com/dotnet/msbuild/issues/6193
## Community contributions
* [MSBuild overview](Contributions/MSBuild-overview.md)
* [Solution parser](Contributions/solution-parser.md)
Note: community contributions has documentation that was contributed by developers or users, but it might not been fully vetted for accuracy and correctness. Explanations in this folder may not be fully accurate, but can still be very informative for developing an understanding of MSBuild or a specific problem.

Просмотреть файл

@ -1,3 +1,5 @@
# When globbing returns original filespec
Original itemspec is returned when:
- illegal filespec contains
- both wildcards and escaped wildcards (`%2a`, `%3f`)

Просмотреть файл

@ -1,21 +0,0 @@
# When should we use FancyLogger
The FancyLogger presents the user with the build's most relevant information at the time, automatically hiding all the information that is no longer relevant (as to prevent huge log outputs). However, many users might find this not very useful (or even counterproductive) such as those using a terminal without proper ANSI support or when redirecting the output to a file. For that reason, the users must be able to turn this feature on/off at will.
# Proposal
Using the `/fancylogger` or `/flg` command line switches, users are able to opt-in and use the FancyLogger, EXCEPT when:
- The terminal does not support ANSI codes or color
- [ ] Detect if terminal does not support ANSI codes or color
- Output is redirected to a file or pipe
- [x] Detect if terminal output is redirected
For early development stages, an environment variable `$MSBUILDFANCYLOGGER` should be enabled to prevent accidental access to an unfinished feature.
In cases where the FancyLogger should not be enabled, the default ConsoleLogger should be used instead.
# Considerations
## Should FancyLogger be used with other loggers (eg, BinaryLogger, FileLogger, custom loggers)?
FancyLogger should only replace the current ConsoleLogger for the aforementioned cases. Additionally, other loggers can be used in conjunction.
## Should output be ignored with the `/noconsolelogger` flag enabled?
FancyLogger serves as a replacement for ConsoleLogger, so it should behave similarly. When attaching the `/noconsolelogger` flag, it should not output anything.

Просмотреть файл

@ -0,0 +1,19 @@
# When should we use LiveLogger
The LiveLogger presents the user with the build's most relevant information at the time, automatically hiding all the information that is no longer relevant (as to prevent huge log outputs). However, many users might find this not very useful (or even counterproductive) such as those using a terminal without proper ANSI support or when redirecting the output to a file. For that reason, the users must be able to turn this feature on/off at will.
# Proposal
Using the `/livelogger` or `/ll` command line switches, users are able to opt-in and use the LiveLogger, EXCEPT when:
- The terminal does not support ANSI codes or color
- Output is redirected to a file or pipe
For early development stages, an environment variable `$MSBUILDLIVELOGGER` should be enabled to prevent accidental access to an unfinished feature.
In cases where the LiveLogger should not be enabled, the default ConsoleLogger should be used instead.
# Considerations
## Should LiveLogger be used with other loggers (eg, BinaryLogger, FileLogger, custom loggers)?
LiveLogger should only replace the current ConsoleLogger for the aforementioned cases. Additionally, other loggers can be used in conjunction.
## Should output be ignored with the `/noconsolelogger` flag enabled?
LiveLogger serves as a replacement for ConsoleLogger, so it should behave similarly. When attaching the `/noconsolelogger` flag, it should not output anything.

Просмотреть файл

@ -1,10 +1,10 @@
# Summary
Project cache is a new assembly-based plugin extension point in MSBuild which determines whether a build request (a project) can be skipped during build. The main expected benefit is reduced build times via [caching and/or distribution](https://github.com/dotnet/msbuild/blob/master/documentation/specs/static-graph.md#weakness-of-the-old-model-caching-and-distributability).
Project cache is a new assembly-based plugin extension point in MSBuild which determines whether a build request (a project) can be skipped during build. The main expected benefit is reduced build times via [caching and/or distribution](https://github.com/dotnet/msbuild/blob/main/documentation/specs/static-graph.md#weakness-of-the-old-model-caching-and-distributability).
# Motivation
As the introduction to [static graph](https://github.com/dotnet/msbuild/blob/master/documentation/specs/static-graph.md#what-is-static-graph-for) suggests, large and complex repos expose the weaknesses in MSBuild's scheduling and incrementality models as build times elongate. This project cache plugin lets MSBuild natively communicate with existing tools that enable build caching and/or distribution, enabling true scalability.
As the introduction to [static graph](https://github.com/dotnet/msbuild/blob/main/documentation/specs/static-graph.md#what-is-static-graph-for) suggests, large and complex repos expose the weaknesses in MSBuild's scheduling and incrementality models as build times elongate. This project cache plugin lets MSBuild natively communicate with existing tools that enable build caching and/or distribution, enabling true scalability.
Visual Studio is one beneficiary. This plugin inverts dependencies among build systems: instead of higher level build engines ([Cloudbuild](https://www.microsoft.com/research/publication/cloudbuild-microsofts-distributed-and-caching-build-service/), [Anybuild](https://github.com/AnyBuild/AnyBuild), [BuildXL](https://github.com/microsoft/BuildXL), etc) calling into MSBuild, MSBuild calls into them, keeping MSBuild's external APIs and command line arguments largely unchanged and thus reusable by Visual Studio.
@ -78,7 +78,7 @@ This change also simplifies and unifies user experiences. MSBuild works the same
- On cache hits, MSBuild skips the project, but needs a BuildResult with target results to send back to the [Scheduler](https://github.com/dotnet/msbuild/blob/d39f2e4f5f3d461bc456f9abed9adec4a2f0f542/src/Build/BackEnd/Components/Scheduler/Scheduler.cs#L25).
- Plugins have three options:
- Worst: plugins fake the build results for each target. We consider this brittle since the plugins will have to be updated whenever the build logic changes.
- Better: plugins tell MSBuild to run a proxy target as a replacement for the expensive target (e.g. it tells MSBuild to run `GetTargetPath` and use those results for the Build target). See the [ProjectReference protocol](https://github.com/dotnet/msbuild/blob/master/documentation/ProjectReference-Protocol.md) for more details.
- Better: plugins tell MSBuild to run a proxy target as a replacement for the expensive target (e.g. it tells MSBuild to run `GetTargetPath` and use those results for the Build target). See the [ProjectReference protocol](https://github.com/dotnet/msbuild/blob/main/documentation/ProjectReference-Protocol.md) for more details.
- Proxy target assumptions:
- They are very fast and only retrieve items and properties from the evaluated state (like `GetTargetPath`).
- They do not mutate state (file system, environment variables, etc).
@ -105,7 +105,7 @@ This change also simplifies and unifies user experiences. MSBuild works the same
- Absolute paths will likely break the build, since they'd be captured on the machine that writes to the cache.
- Slow connections. In a coffee shop it might be faster to build everything instead of downloading from the cache. Consider racing plugin checks and building: if the bottom up build traversal reaches a node that's still querying the cache, cancel the cache query and build the node instead.
- Inferring what targets to run on each node when using /graph
- Msbuild /graph requires that the [target inference protocol](https://github.com/dotnet/msbuild/blob/master/documentation/specs/static-graph.md#inferring-which-targets-to-run-for-a-project-within-the-graph) is good enough.
- Msbuild /graph requires that the [target inference protocol](https://github.com/dotnet/msbuild/blob/main/documentation/specs/static-graph.md#inferring-which-targets-to-run-for-a-project-within-the-graph) is good enough.
- Small repos will probably be slower with plugin implementations that access the network. Remote distribution and caching will only be worth it for repos that are large enough.
# Future work

Просмотреть файл

@ -25,4 +25,35 @@ Note, that the manifest file, if exists, from ChangeWave 17.4 would have prefere
The sdk discovery works according to the following algorithm:
- First try locate the manifest file and use it.
- If it is not found, we try to locate the dll in the resolver's folder.
Both xml and dll name should match the following name pattern `...\SdkResolvers\(ResolverName)\(ResolverName).(xml/dll)`.
Both xml and dll name should match the following name pattern `...\SdkResolvers\(ResolverName)\(ResolverName).(xml/dll)`.
### Failed SDK Resolution
> 🚧 Note
>
> This page is a work in progress.
SDK resolvers previously attempted to continue when one critically fails (throws an unhandled exception). This lead to misleading error messages such as:
```
warning MSB4242: The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed to run. 's' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8.
error MSB4236: The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found. [C:\foo\bar.csproj]
```
`MSB4236` is a red herring while `MSB4242` is the real error despite being logged as a warning. Because of this, SDK resolvers now fail the build _immediately_ upon unhandled exceptions. These exceptions are propogated as `SdkResolverException`s, and `MSB4242` has been promoted to an error code. The new error message appears like so:
```
C:\src\temp\8-18>"C:\foo\dotnet-sdk-6.0.100-preview.7.21379.14-win-x64\dotnet.exe" build
Microsoft (R) Build Engine version 17.0.0-dev-21420-01+5df152759 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
C:\foo\bar.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "'s' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8."".
Build FAILED.
C:\foo\bar.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "'s' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8."".
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.15
```

Просмотреть файл

@ -1,29 +0,0 @@
> 🚧 Note
>
> This page is a work in progress.
### Failed SDK Resolution
SDK resolvers previously attempted to continue when one critically fails (throws an unhandled exception). This lead to misleading error messages such as:
```
warning MSB4242: The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed to run. 's' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8.
error MSB4236: The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found. [C:\foo\bar.csproj]
```
`MSB4236` is a red herring while `MSB4242` is the real error despite being logged as a warning. Because of this, SDK resolvers now fail the build _immediately_ upon unhandled exceptions. These exceptions are propogated as `SdkResolverException`s, and `MSB4242` has been promoted to an error code. The new error message appears like so:
```
C:\src\temp\8-18>"C:\foo\dotnet-sdk-6.0.100-preview.7.21379.14-win-x64\dotnet.exe" build
Microsoft (R) Build Engine version 17.0.0-dev-21420-01+5df152759 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
C:\foo\bar.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "'s' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8."".
Build FAILED.
C:\foo\bar.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "'s' is an invalid start of a property name. Expected a '"'. LineNumber: 14 | BytePositionInLine: 8."".
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.15
```

Просмотреть файл

@ -12,7 +12,7 @@ The presence of either input or output caches turns on [isolated build constrain
## Input / Output cache implementation
<!-- cache structure -->
The cache files contain the serialized state of MSBuild's [ConfigCache](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ConfigCache.cs) and [ResultsCache](https://github.com/dotnet/msbuild/blob/master/src/Build/BackEnd/Components/Caching/ResultsCache.cs). These two caches have been traditionally used by the engine to cache build results. For example, it is these caches which ensure that a target is only built once per build submission. The `ConfigCache` entries are instances of [BuildRequestConfiguration](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/BuildRequestConfiguration.cs#L25). The `ResultsCache` entries are instances of [BuildResult](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/BuildResult.cs#L34), which contain or more instances of [TargetResult](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/TargetResult.cs#L22).
The cache files contain the serialized state of MSBuild's [ConfigCache](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ConfigCache.cs) and [ResultsCache](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ResultsCache.cs). These two caches have been traditionally used by the engine to cache build results. For example, it is these caches which ensure that a target is only built once per build submission. The `ConfigCache` entries are instances of [BuildRequestConfiguration](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/BuildRequestConfiguration.cs#L25). The `ResultsCache` entries are instances of [BuildResult](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/BuildResult.cs#L34), which contain or more instances of [TargetResult](https://github.com/dotnet/msbuild/blob/37c5a9fec416b403212a63f95f15b03dbd5e8b5d/src/Build/BackEnd/Shared/TargetResult.cs#L22).
One can view the two caches as the following mapping: `(project path, global properties) -> results`. `(project path, global properties)` is represented by a `BuildRequestConfiguration`, and the results are represented by `BuildResult` and `TargetResult`.
@ -30,7 +30,7 @@ The following constraints are enforced during cache aggregation:
The output cache file **only contains results for additional work performed in the current BeginBuild / EndBuild session**. Entries from input caches are not transferred to the output cache.
<!-- How input / output cache entries are separated with the override caches -->
Entries that make it into the output cache file are separated from entries serialized from input cache files via the use of [ConfigCacheWithOverride](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ConfigCacheWithOverride.cs) and [ResultsCacheWithOverride](https://github.com/dotnet/msbuild/blob/master/src/Build/BackEnd/Components/Caching/ResultsCacheWithOverride.cs). These are composite caches. Each contains two underlying caches: a cache where input caches files are loaded into (called the override cache), and a cache where new results are written into (called the current cache). Cache reads are satisified from both underlying caches (override cache is queried first, current cache is queried second). Writes are only written to the current cache, never into the override cache. The output cache file only contains the serialized current cache, and not the override cache, thus ensuring that only newly built results are serialized in the output cache file. It is illegal for both the current cache and override cache to contain entries for the same project configuration, a constraint that is checked by the two override caches on each cache read.
Entries that make it into the output cache file are separated from entries serialized from input cache files via the use of [ConfigCacheWithOverride](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ConfigCacheWithOverride.cs) and [ResultsCacheWithOverride](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Caching/ResultsCacheWithOverride.cs). These are composite caches. Each contains two underlying caches: a cache where input caches files are loaded into (called the override cache), and a cache where new results are written into (called the current cache). Cache reads are satisified from both underlying caches (override cache is queried first, current cache is queried second). Writes are only written to the current cache, never into the override cache. The output cache file only contains the serialized current cache, and not the override cache, thus ensuring that only newly built results are serialized in the output cache file. It is illegal for both the current cache and override cache to contain entries for the same project configuration, a constraint that is checked by the two override caches on each cache read.
## Isolation implementation

Просмотреть файл

@ -23,7 +23,7 @@ We also want to load groups of tasks which belong together into the same ALC (fo
# Task dependency resolution
## Problem definition
Tasks with complex and specifically platform specific dependencies don't work out of the box. For example if a task uses [`LibGit2Sharp`](https://www.nuget.org/packages/LibGit2Sharp) package it will not work as is. `LibGit2Sharp` has native dependencies which are platform specific. While the package carries all of them, there's no built in support for the task to load the right ones. For example [source link](https://github.com/dotnet/sourcelink/blob/master/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs) runs into this problem.
Tasks with complex and specifically platform specific dependencies don't work out of the box. For example if a task uses [`LibGit2Sharp`](https://www.nuget.org/packages/LibGit2Sharp) package it will not work as is. `LibGit2Sharp` has native dependencies which are platform specific. While the package carries all of them, there's no built in support for the task to load the right ones. For example [source link](https://github.com/dotnet/sourcelink/blob/29b3197e824c05d03427c05d56700e4c704233e4/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs) runs into this problem.
## Solution
.NET Core uses `.deps.json` files to describe dependencies of components. It would be natural to treat task assemblies as components and use associated .deps.json file to determine their dependencies. This would make the system work nicely end to end with the .NET Core CLI/SDK and VS integration.

Просмотреть файл

@ -66,12 +66,7 @@ https://msbuildlog.com/
# Collecting binary logs from Visual Studio builds
If you need to capture a binary log in Visual Studio, instead of the command line, you'll need a Visual Studio plugin:
- https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools for VS 2017 & 2019
- https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022 for VS 2022
After installing that, enable logging and run your build ([more details](https://github.com/dotnet/project-system-tools)).
[see more details](Providing-Binary-Logs.md#capturing-binary-logs-through-visual-studio)
# Binary log file format

Просмотреть файл

@ -1,6 +1,6 @@
# Building MSBuild for the .NET Framework
These instructions refer to working with the `master` branch.
These instructions refer to working with the `main` branch.
## Required Software

Просмотреть файл

@ -27,6 +27,7 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t
- [Parse invalid property under target](https://github.com/dotnet/msbuild/pull/8190)
- [Eliminate project string cache](https://github.com/dotnet/msbuild/pull/7965)
- [Log an error when no provided search path for an import exists](https://github.com/dotnet/msbuild/pull/8095)
- [Log assembly loads](https://github.com/dotnet/msbuild/pull/8316)
### 17.4
- [Respect deps.json when loading assemblies](https://github.com/dotnet/msbuild/pull/7520)

Просмотреть файл

@ -5,7 +5,7 @@ Because our focus right now is on maintaining backwards compatibility, the team
- Contributions must be discussed with the team first, or they will likely be declined. As our process matures and our experience grows, the team expects to take larger contributions.
- Only contributions referencing an approved Issue will be accepted.
- Pull requests that do not merge easily with the tip of the master branch will be declined. The author will be asked to merge with tip and submit a new pull request.
- Pull requests that do not merge easily with the tip of the main branch will be declined. The author will be asked to merge with tip and submit a new pull request.
- Submissions must meet functional and performance expectations, including scenarios for which the team doesn't yet have open source tests. This means you may be asked to fix and resubmit your pull request against a new open test case if it fails one of these tests.
- Submissions must follow the [.NET Runtime Coding Guidelines](https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/coding-style.md)

Просмотреть файл

@ -1,3 +1,5 @@
# Interactions with the internal repository
MSbuild got forked from an internal Microsoft repository. Although the Github repository is the official one, where development takes place, there are still some left-over connections to the internal one. This page attempts to document these.
Changes to these files need to be migrated back into the internal repo because that's where they are localized:

Просмотреть файл

@ -21,8 +21,8 @@
## Process for interacting with the localization team
- 3 weeks cadence for master, initiated by loc team
- on demand for master / release branches, initiated by msbuild team
- 3 weeks cadence for main, initiated by loc team
- on demand for main / release branches, initiated by msbuild team
## Contributing a better translation

Просмотреть файл

@ -1,6 +1,6 @@
#Debugging with MacOS
# Debugging with MacOS
* Open terminal
* Hit command-space, type terminal, hit enter. Alternatively, hit magnifying glass (spotlight) in upper-right corner and search for terminal.)
* Hit command-space, type terminal, hit enter. Alternatively, hit magnifying glass (spotlight) in upper-right corner and search for terminal.
* Build and run tests
* Navigation in terminal is similar to command prompt (cd), although you type `ls` in place of `dir`.
* **Use `./build.sh -test` instead of `.\build.cmd -test`.**

Просмотреть файл

@ -0,0 +1,72 @@
Transcript of a talk with Rainer - [internal link] [recording](https://msit.microsoftstream.com/video/fde00840-98dc-ba75-0ebd-f1ed9ca0e097)
## Need for multiple processes
MSBuild is multiprocess system today.
Multiple processes are used in few scenarios:
1) **TaskHost** - allowing to run back compatible tasks and MSBuild plugins requiring different runtime.
Task declares (in [UsingTask](https://learn.microsoft.com/en-us/visualstudio/msbuild/usingtask-element-msbuild)) what environment it expects, and if it's not compatible with current configuration (today for VS that's x64 net4) - it'll be isolated.
[GenerateResource](https://learn.microsoft.com/en-us/visualstudio/msbuild/generateresource-task) task uses this (used to use this).
`TaskHost` is supported so far, but performance is not closely watched.
Currently, [MSBuild running on .NET Core cannot run tasks compiled against the full desktop .NET environment](https://github.com/dotnet/msbuild/issues/711). Analogously, [.NET core tasks cannot be run from Visual Studio](https://github.com/dotnet/msbuild/issues/4834).
2) **Parallel builds** - needed since tasks can access process wide state - namely current working dir, environment vars. Those can change between projects (especially [`Compile Include`](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-items) often contains relative path, without specifying `$MSBuildProjectDirectory` - so it relies on current directory being the location of the project file). For this reason node in parallel build can run only one task at a time.
## Communication
In a presence of multiple processes we need interprocess communication.
### Messages (de)serialization
Communication messages should deriver from [`ITranslatable`](https://github.com/dotnet/msbuild/blob/main/src/Shared/ITranslatable.cs) - it dictates the both direction of serialization via single method - [`void Translate(ITranslator translate)`](https://github.com/dotnet/msbuild/blob/main/src/Shared/ITranslatable.cs#L16)
Majority of translations use custom binary serialization, there is though backfall to [`TranslateDoteNet`](https://github.com/dotnet/msbuild/blob/main/src/Shared/ITranslator.cs#L257) method that uses `BinaryFormatter`.
Event args use different type of serialization - a `CreateFromStream` and `WriteToStream` methods are discovered via reflection and used to serialize type (with few exceptions explicitly translated within [`LogMessagePacketBase`](https://github.com/dotnet/msbuild/blob/main/src/Shared/LogMessagePacketBase.cs)).
### Transport
Endpoints (nodes) communicate via named pipes (Windows or named pipes API implementation on other plaforms). Communication is facilitated via [`NodeProviderOutOfProcBase`](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs)
The validation of transport is done via [proprietary handshake](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs#L501-L508).
## Orchestration
MSBuild consist of nodes. First spun is so called **entrypoint node**. It runs a **scheduler**. Then there are **worker nodes** - those can only execute projects. Nodes are spun by [`NodeLauncher`](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Communications/NodeLauncher.cs) - this is being called from [`NodeProviderOutOfProcBase.GetNodes`](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs#L186) (which can decide to reuse existing node or start a new process), that is ultimately called by [`NodeManger`](https://github.com/dotnet/msbuild/blob/main/src/Deprecated/Engine/Engine/NodeManager.cs).
`NodeManager` is a build component (`IBuildComponent`) - so it can be retrieved from build engine (via `IBuildComponentHost.GetComponent`).
Node is described by [`NodeInfo`](https://github.com/dotnet/msbuild/blob/main/src/Build/BackEnd/Components/Communications/NodeInfo.cs).
MSBuild can be started from existing process via API, or via MSBuild.exe - in both cases this process becomes a `scheduler node` and may or may not run other work in-process. By default the main process has as well a `worker node` (project build node). This can be tweaked by API and/or [environment variables](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#configure-msbuild-in-the-net-cli).
When MSBuild start building a project it can eventually start processing MSBuild task that has [`BuildInParallel`](https://learn.microsoft.com/en-us/visualstudio/msbuild/building-multiple-projects-in-parallel-with-msbuild?view=vs-2022) set to `true` (which is a default) and multiple projects to build (e.g. a project with multiple `ProjectReference` elements) at that point `scheduler` orchestrates multiple `worker nodes` via `NodeManager` (upper limited via maximum parallelization - configurable via API or CLI (`-maxcpucount|-m`)) .
Bugs in node communication layer can manifest as a slow build - otherwise fully functional. As `NodeManager` is trying to setup new nodes (and failing) and `scheduler` is working with only a single (in-proc) node that it has.
Work unit for nodes is a `project instance` - a project together with set of glabal properties that make the project unique.
----
**Example:**
Multitargeted project (`TargetFrameworks=x;Y`) - this will generate 'outer-build' - a project with no global properties set; and 'inner build' for each `TargetFramework` (so one instance with `TargetFramework=X`, `TargetFramework=Y`). All those are distinct - so can be scheduled on separate nodes (in practice the outer build is scheduled on a node, hits the `ResolveProjectReferences` that will produce the two projects for particular `TargetFramework` - one is scheduled on the same node, other one waits for a different node to be available/spun).
----
MSBuild scheduler maintains a list of projects that are eligible to run (not blocked) and list of free worker nodes (plus knows a mapping of projects already mapped to particular nodes) and maps the work. [It performs some heuristics](https://github.com/dotnet/msbuild/blob/7cfb36cb90d1c9cc34bc4e0910d0c9ef42ee47b6/src/Build/BackEnd/Components/Scheduler/Scheduler.cs#L776-L783) prioritizing work that is likely to request more work (e.g. dir.proj files).
## Scheduler assumptions
Node in parallel build can run only one task at a time (task can explicitly temporarily vacate the node via `IBuildEngine.Yield`, or this can implicitly happen when MSBuild discovers dependencies on tasks that have not run yet)
Once a `project instance` is assigned to a worker node - it is locked to that node (and cannot be run on another one). Above 2 facts can lead to scheduling issues (priorities inversions, blocking).
Scheduler can (opt-in) dump a graph of dependencies from last build into a text file and then use it in the next build (with option of [various scheduling algorithms](https://github.com/dotnet/msbuild/blob/7cfb36cb90d1c9cc34bc4e0910d0c9ef42ee47b6/src/Build/BackEnd/Components/Scheduler/Scheduler.cs#L833))
Another mode of building is `graph build` - where project is build only once all its dependencies are resolved (so the build graph needs to be known and unchanged upfront).

Просмотреть файл

@ -6,9 +6,35 @@ However, you should be aware what type of information is captured in the binary
⚠ NOTE: some build environments make secrets available using environment variables. Before sharing a binary log, make sure it does not expose API tokens or other important secrets.
You can create a binary log by passing the `-bl` parameter to MSBuild. You can explore the contents of the generated .binlog file using [MSBuild Structured Log Viewer](http://msbuildlog.com/) or in your browser using [Live Structured Log Viewer](https://live.msbuildlog.com). Note: We don't capture any data from binary logs viewed on your browser.
You can create a binary log by passing the `-bl` parameter to MSBuild (`MSBuild.exe` or `dotnet build`). You can explore the contents of the generated .binlog file using [MSBuild Structured Log Viewer](http://msbuildlog.com/) or in your browser using [Live Structured Log Viewer](https://live.msbuildlog.com). Note: We don't capture any data from binary logs viewed on your browser.
[More details about binary logs](Binary-Log.md)
## Capturing Binary Logs Through Visual Studio
See [this guide](https://github.com/dotnet/project-system-tools) in the Project System Tools repo for capturing binlogs through Visual Studio.
### (Preferred way) Capturing logs for all MSBuild invocations
Set `MSBUILDDEBUGENGINE` environment variable to `'1'` and (optionally) set `MSBUILDDEBUGPATH` to an existing destination folder to store the captured logs. Then start Visual Studio from the same shell to inherit the environment:
`cmd:`
```
> SET MSBUILDDEBUGENGINE=1
> SET MSBUILDDEBUGPATH=C:\MSBuildReproLogs
> devenv.exe MySolution.sln
```
`PowerShell:`
```
> $env:MSBUILDDEBUGENGINE = 1
> $env:MSBUILDDEBUGPATH= C:\MSBuildReproLogs
> & "devenv.exe" MySolution.sln
```
MSBuild binary logs are then captured to a location specified via `MSBUILDDEBUGPATH` environment variable (or defaults to `MSBuild_Logs` subfolder of a current folder or `%temp%`, based on access rights).
⚠ NOTE: logs are being recorded for each MSBuild invocation (including design time builds) and kept in the folder without removing older ones - so the number of log files can grow quickly. It is recommended to set the opt-in environment variable only for the short duration of reproducing the issue to be investigated (though it is understandable that some nondeterministic issues might need multiple reproduction attempts)
Further reading:
* [More technical info](Building-Testing-and-Debugging-on-Full-Framework-MSBuild.md#logs)
* [Design time builds logs](https://github.com/dotnet/project-system/blob/main/docs/repo/debugging/design-time-builds.md#gathering-full-fidelity-binlogs)
### Capturing specific logs for chosen build invocations
See [this guide](https://github.com/dotnet/project-system-tools) in the Project System Tools repo for capturing binlogs through Visual Studio.

Просмотреть файл

@ -782,10 +782,10 @@ dotnet_diagnostic.SA1107.severity = suggestion
dotnet_diagnostic.SA1108.severity = none
# Opening parenthesis or bracket should be on declaration line
dotnet_diagnostic.SA1110.severity = suggestion
dotnet_diagnostic.SA1110.severity = warning
# Closing parenthesis should be on line of last parameter
dotnet_diagnostic.SA1111.severity = suggestion
dotnet_diagnostic.SA1111.severity = warning
dotnet_diagnostic.SA1112.severity = none
@ -1093,7 +1093,8 @@ dotnet_diagnostic.SA1627.severity = suggestion
dotnet_diagnostic.SA1629.severity = suggestion
# File should have header
dotnet_diagnostic.SA1633.severity = suggestion
# Superseded by IDE0073
dotnet_diagnostic.SA1633.severity = none
# Constructor summary documentation should begin with standard text
dotnet_diagnostic.SA1642.severity = suggestion

Просмотреть файл

@ -8,29 +8,28 @@
the list of assemblies redistributed by MSBuild (non-MSBuild assemblies in the .vsix package).
-->
<ItemGroup>
<PackageReference Update="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Build.Tasks" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageReference Update="Microsoft.CodeAnalysis.Collections" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
<PackageReference Update="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
<PackageReference Update="Microsoft.IO.Redist" Version="$(MicrosoftIORedistVersion)" />
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageReference Update="NuGet.Build.Tasks" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="NuGet.Frameworks" Version="$(NuGetBuildTasksVersion)" />
<PackageReference Update="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageReference Update="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerVersion)" />
<PackageReference Update="System.Memory" Version="$(SystemMemoryVersion)" />
<PackageReference Update="System.Net.Http" Version="$(SystemNetHttpVersion)" />
<PackageReference Update="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
<PackageReference Update="System.Reflection.MetadataLoadContext" Version="$(SystemReflectionMetadataLoadContextVersion)" />
<PackageReference Update="System.Resources.Extensions" Version="$(SystemResourcesExtensionsPackageVersion)" />
<PackageReference Update="System.Runtime.CompilerServices.Unsafe" Version="$(SystemRuntimeCompilerServicesUnsafeVersion)" />
<PackageReference Update="System.Security.Permissions" Version="$(SystemSecurityPermissionsVersion)" />
<PackageReference Update="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
<PackageReference Update="System.Text.Encoding.CodePages" Version="$(SystemTextEncodingCodePagesVersion)" />
<PackageReference Update="System.Text.Json" Version="$(SystemTextJsonVersion)" />
<PackageReference Update="System.Threading.Tasks.Dataflow" Version="$(SystemThreadingTasksDataflowVersion)" />
<PackageReference Update="xunit.assert" Version="$(XUnitVersion)" />
<PackageReference Update="xunit.console" Version="$(XUnitVersion)" />
<PackageReference Update="xunit.core" Version="$(XUnitVersion)" />
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(NuGetBuildTasksVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Build.Tasks" Version="$(MicrosoftNetCompilersToolsetVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Collections" Version="$(MicrosoftCodeAnalysisCollectionsVersion)" />
<PackageVersion Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
<PackageVersion Include="Microsoft.IO.Redist" Version="$(MicrosoftIORedistVersion)" />
<PackageVersion Include="NuGet.Build.Tasks" Version="$(NuGetBuildTasksVersion)" />
<PackageVersion Include="NuGet.Frameworks" Version="$(NuGetBuildTasksVersion)" />
<PackageVersion Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerVersion)" />
<PackageVersion Include="System.Memory" Version="$(SystemMemoryVersion)" />
<PackageVersion Include="System.Net.Http" Version="$(SystemNetHttpVersion)" />
<PackageVersion Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
<PackageVersion Include="System.Reflection.MetadataLoadContext" Version="$(SystemReflectionMetadataLoadContextVersion)" />
<PackageVersion Include="System.Resources.Extensions" Version="$(SystemResourcesExtensionsPackageVersion)" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="$(SystemRuntimeCompilerServicesUnsafeVersion)" />
<PackageVersion Include="System.Security.Permissions" Version="$(SystemSecurityPermissionsVersion)" />
<PackageVersion Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="$(SystemTextEncodingCodePagesVersion)" />
<PackageVersion Include="System.Text.Json" Version="$(SystemTextJsonVersion)" />
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="$(SystemThreadingTasksDataflowVersion)" />
<PackageVersion Include="xunit.assert" Version="$(XUnitVersion)" />
<PackageVersion Include="xunit.console" Version="$(XUnitVersion)" />
<PackageVersion Include="xunit.core" Version="$(XUnitVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -3,6 +3,7 @@
<PropertyGroup>
<GitHubRepositoryName>msbuild</GitHubRepositoryName>
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>
<SourceBuildTrimNetFrameworkTargets>true</SourceBuildTrimNetFrameworkTargets>
</PropertyGroup>
<Target Name="ConfigureInnerBuildArgs" BeforeTargets="GetSourceBuildCommandConfiguration">

Просмотреть файл

@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.22601.5">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.23114.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>4255f0e27aa7ca1065962df22b65e4f2b0cd9a4c</Sha>
<Sha>0c93c1cb1ef9c9d5c1a59f4ab98c2f7e37f12197</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="NuGet.Build.Tasks" Version="6.5.0-preview.3.126">
<Dependency Name="NuGet.Build.Tasks" Version="6.5.0-rc.149">
<Uri>https://github.com/nuget/nuget.client</Uri>
<Sha>31f2a1cb6fe3dababe67cdb84e9d6ddb9e3ace04</Sha>
<Sha>ca5029046d7b6e55f322c45abb7b342054543710</Sha>
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.5.0-2.22608.26">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.6.0-2.23166.9">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>716366a3830293571eaaad9b1b2b3929b5216f42</Sha>
<Sha>48b13597fee9df5ecfbd0b8c0758b3f46bc1d440</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.22601.5">
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.23114.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>4255f0e27aa7ca1065962df22b65e4f2b0cd9a4c</Sha>
<Sha>0c93c1cb1ef9c9d5c1a59f4ab98c2f7e37f12197</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

Просмотреть файл

@ -2,8 +2,8 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.5.2</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.4.0</PackageValidationBaselineVersion>
<VersionPrefix>17.6.0</VersionPrefix>
<PackageValidationBaselineVersion>17.5.0-preview-23075-01</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
@ -26,8 +26,8 @@
</PropertyGroup>
<!-- Production Dependencies -->
<PropertyGroup>
<SystemCollectionsImmutableVersion>6.0.0</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>6.0.0</SystemConfigurationConfigurationManagerVersion>
<SystemCollectionsImmutableVersion>7.0.0</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>7.0.0</SystemConfigurationConfigurationManagerVersion>
<!--
Modifying the version of System.Memory is very high impact and causes downstream breaks in third-party tooling that uses the MSBuild API.
When updating the version of System.Memory file a breaking change here: https://github.com/dotnet/docs/issues/new?assignees=gewarren&labels=breaking-change%2CPri1%2Cdoc-idea&template=breaking-change.yml&title=%5BBreaking+change%5D%3A+
@ -35,12 +35,12 @@
-->
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
<SystemNetHttpVersion>4.3.4</SystemNetHttpVersion>
<SystemReflectionMetadataLoadContextVersion>6.0.0</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionMetadataVersion>6.0.0</SystemReflectionMetadataVersion>
<SystemResourcesExtensionsPackageVersion>6.0.0</SystemResourcesExtensionsPackageVersion>
<SystemSecurityPermissionsVersion>6.0.0</SystemSecurityPermissionsVersion>
<SystemReflectionMetadataLoadContextVersion>7.0.0</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionMetadataVersion>7.0.0</SystemReflectionMetadataVersion>
<SystemResourcesExtensionsPackageVersion>7.0.0</SystemResourcesExtensionsPackageVersion>
<SystemSecurityPermissionsVersion>7.0.0</SystemSecurityPermissionsVersion>
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
<SystemTextEncodingCodePagesVersion>6.0.0</SystemTextEncodingCodePagesVersion>
<SystemTextEncodingCodePagesVersion>7.0.0</SystemTextEncodingCodePagesVersion>
</PropertyGroup>
<!-- Toolset Dependencies -->
<PropertyGroup>
@ -48,14 +48,14 @@
Otherwise, this version of dotnet will not be installed and the build will error out. -->
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)..\global.json')), '"dotnet": "([^"]*)"').Groups.get_Item(1))</DotNetCliVersion>
<MicrosoftCodeAnalysisCollectionsVersion>4.2.0-1.22102.8</MicrosoftCodeAnalysisCollectionsVersion>
<MicrosoftDotNetXUnitExtensionsVersion>6.0.0-beta.22601.5</MicrosoftDotNetXUnitExtensionsVersion>
<MicrosoftExtensionsDependencyModelVersion>6.0.0-preview.2.21154.6</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftDotNetXUnitExtensionsVersion>6.0.0-beta.23114.5</MicrosoftDotNetXUnitExtensionsVersion>
<MicrosoftExtensionsDependencyModelVersion>7.0.0</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftIORedistVersion>6.0.0</MicrosoftIORedistVersion>
<MicrosoftNetCompilersToolsetVersion>4.5.0-2.22608.26</MicrosoftNetCompilersToolsetVersion>
<NuGetBuildTasksVersion>6.5.0-preview.3.126</NuGetBuildTasksVersion>
<MicrosoftNetCompilersToolsetVersion>4.6.0-2.23166.9</MicrosoftNetCompilersToolsetVersion>
<NuGetBuildTasksVersion>6.5.0-rc.149</NuGetBuildTasksVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemTextJsonVersion>6.0.0</SystemTextJsonVersion>
<SystemThreadingTasksDataflowVersion>6.0.0</SystemThreadingTasksDataflowVersion>
<SystemTextJsonVersion>7.0.0</SystemTextJsonVersion>
<SystemThreadingTasksDataflowVersion>7.0.0</SystemThreadingTasksDataflowVersion>
</PropertyGroup>
<Target Name="OverrideArcadeFileVersion" AfterTargets="_InitializeAssemblyVersion">
<!-- See https://github.com/dotnet/arcade/issues/3386

Просмотреть файл

@ -169,7 +169,7 @@ function Check-RequiredVersionBumps() {
if (($LASTEXITCODE -ne 0) -and (-not $versionLineChanged)) {
throw "##vso[task.logissue type=error] Detected changes in Framework\EngineServices.cs without a version bump. " +
"If you are making API changes, please bump the version. " +
"If the changes in the file are cosmetic, please add/change a comment on the Version prop to silence the error."
"If the changes in the file are cosmetic, please change an inline comment on the `"int Version =`" line in EngineServices.cs to silence the error."
}
}
}

Просмотреть файл

@ -10,51 +10,48 @@
these properties to override package versions if necessary. -->
<ItemGroup>
<PackageReference Update="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Update="BenchmarkDotNet" Condition="'$(BenchmarkDotNetVersion)' != ''" Version="$(BenchmarkDotNetVersion)" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.1" />
<PackageVersion Update="BenchmarkDotNet" Condition="'$(BenchmarkDotNetVersion)' != ''" Version="$(BenchmarkDotNetVersion)" />
<PackageReference Update="LargeAddressAware" Version="1.0.5" />
<PackageReference Update="LargeAddressAware" Condition="'$(LargeAddressAwareVersion)' != ''" Version="$(LargeAddressAwareVersion)" />
<PackageVersion Include="LargeAddressAware" Version="1.0.5" />
<PackageVersion Update="LargeAddressAware" Condition="'$(LargeAddressAwareVersion)' != ''" Version="$(LargeAddressAwareVersion)" />
<PackageReference Update="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.36" />
<PackageReference Update="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Condition="'$(MicrosoftVisualStudioSDKEmbedInteropTypesVersion)' != ''" Version="$(MicrosoftVisualStudioSDKEmbedInteropTypesVersion)" />
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.2.2146" PrivateAssets="All" />
<PackageVersion Update="Microsoft.VisualStudio.Setup.Configuration.Interop" Condition="'$(MicrosoftVisualStudioSetupConfigurationInteropVersion)' != ''" Version="$(MicrosoftVisualStudioSetupConfigurationInteropVersion)" PrivateAssets="All" />
<PackageReference Update="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.2.2146" PrivateAssets="All" />
<PackageReference Update="Microsoft.VisualStudio.Setup.Configuration.Interop" Condition="'$(MicrosoftVisualStudioSetupConfigurationInteropVersion)' != ''" Version="$(MicrosoftVisualStudioSetupConfigurationInteropVersion)" PrivateAssets="All" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageVersion Update="Microsoft.Win32.Registry" Condition="'$(MicrosoftWin32RegistryVersion)' != ''" Version="$(MicrosoftWin32RegistryVersion)" />
<PackageReference Update="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Update="Microsoft.Win32.Registry" Condition="'$(MicrosoftWin32RegistryVersion)' != ''" Version="$(MicrosoftWin32RegistryVersion)" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />
<PackageVersion Update="Newtonsoft.Json" Condition="'$(NewtonsoftJsonVersion)' != ''" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Update="Newtonsoft.Json" Condition="'$(NewtonsoftJsonVersion)' != ''" Version="$(NewtonsoftJsonVersion)" />
<PackageVersion Include="PdbGit" Version="3.0.41" />
<PackageVersion Update="PdbGit" Condition="'$(PdbGitVersion)' != ''" Version="$(PdbGitVersion)" />
<PackageReference Update="PdbGit" Version="3.0.41" />
<PackageReference Update="PdbGit" Condition="'$(PdbGitVersion)' != ''" Version="$(PdbGitVersion)" />
<PackageVersion Include="Shouldly" Version="3.0.0" />
<PackageVersion Update="Shouldly" Condition="'$(ShouldlyVersion)' != ''" Version="$(ShouldlyVersion)" />
<PackageReference Update="Shouldly" Version="3.0.0" />
<PackageReference Update="Shouldly" Condition="'$(ShouldlyVersion)' != ''" Version="$(ShouldlyVersion)" />
<PackageVersion Include="System.CodeDom" Version="7.0.0" />
<PackageVersion Update="System.CodeDom" Condition="'$(SystemCodeDomVersion)' != ''" Version="$(SystemCodeDomVersion)" />
<PackageReference Update="System.CodeDom" Version="6.0.0" />
<PackageReference Update="System.CodeDom" Condition="'$(SystemCodeDomVersion)' != ''" Version="$(SystemCodeDomVersion)" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Update="System.Private.Uri" Condition="'$(SystemPrivateUriVersion)' != ''" Version="$(SystemPrivateUriVersion)" />
<PackageReference Update="System.Private.Uri" Version="4.3.2" />
<PackageReference Update="System.Private.Uri" Condition="'$(SystemPrivateUriVersion)' != ''" Version="$(SystemPrivateUriVersion)" />
<PackageVersion Include="System.Runtime" Version="4.3.1" />
<PackageVersion Update="System.Runtime" Condition="'$(SystemRuntimeVersion)' != ''" Version="$(SystemRuntimeVersion)" />
<PackageReference Update="System.Runtime" Version="4.3.1" />
<PackageReference Update="System.Runtime" Condition="'$(SystemRuntimeVersion)' != ''" Version="$(SystemRuntimeVersion)" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="7.0.0" />
<PackageVersion Update="System.Security.Cryptography.Pkcs" Condition="'$(SystemSecurityCryptographyPkcsVersion)' != ''" Version="$(SystemSecurityCryptographyPkcsVersion)" />
<PackageReference Update="System.Security.Cryptography.Pkcs" Version="6.0.1" />
<PackageReference Update="System.Security.Cryptography.Pkcs" Condition="'$(SystemSecurityCryptographyPkcsVersion)' != ''" Version="$(SystemSecurityCryptographyPkcsVersion)" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="7.0.1" />
<PackageVersion Update="System.Security.Cryptography.Xml" Condition="'$(SystemSecurityCryptographyXmlVersion)' != ''" Version="$(SystemSecurityCryptographyXmlVersion)" />
<PackageReference Update="System.Security.Cryptography.Xml" Version="6.0.1" />
<PackageReference Update="System.Security.Cryptography.Xml" Condition="'$(SystemSecurityCryptographyXmlVersion)' != ''" Version="$(SystemSecurityCryptographyXmlVersion)" />
<PackageReference Update="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageReference Update="System.Security.Cryptography.X509Certificates" Condition="'$(SystemSecurityCryptographyX509CertificatesVersion)' != ''" Version="$(SystemSecurityCryptographyX509CertificatesVersion)" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
<PackageVersion Update="System.Security.Cryptography.X509Certificates" Condition="'$(SystemSecurityCryptographyX509CertificatesVersion)' != ''" Version="$(SystemSecurityCryptographyX509CertificatesVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true' AND $(ProjectIsDeprecated) != 'true'">
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.3" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all"/>
<GlobalPackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.36" PrivateAssets="All" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
</ItemGroup>

Просмотреть файл

@ -3,14 +3,13 @@
"allowPrerelease": true
},
"tools": {
"dotnet": "7.0.101",
"dotnet": "7.0.200",
"vs": {
"version": "17.4.1"
},
"xcopy-msbuild": "17.4.1"
},
"msbuild-sdks": {
"Microsoft.Build.CentralPackageVersions": "2.0.1",
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.22601.5"
"Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.23114.5"
}
}

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -7,13 +7,11 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Shared;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -110,8 +108,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project2 = ProjectRootElement.Create();
ProjectTargetElement target = project1.CreateTargetElement("t");
project2.AppendChild(target);
}
);
});
}
/// <summary>
/// Add node created from different project with PrependChild
@ -125,8 +122,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project2 = ProjectRootElement.Create();
ProjectTargetElement target = project1.CreateTargetElement("t");
project2.PrependChild(target);
}
);
});
}
/// <summary>
/// Add node created from different project with InsertBeforeChild
@ -141,8 +137,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target1 = project1.CreateTargetElement("t");
ProjectTargetElement target2 = project2.AddTarget("t2");
project2.InsertBeforeChild(target2, target1);
}
);
});
}
/// <summary>
/// Add node created from different project with InsertAfterChild
@ -157,8 +152,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target1 = project1.CreateTargetElement("t");
ProjectTargetElement target2 = project2.AddTarget("t2");
project2.InsertAfterChild(target2, target1);
}
);
});
}
/// <summary>
/// Become direct child of self with AppendChild
@ -173,8 +167,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectChooseElement choose = project.CreateChooseElement();
choose.AppendChild(choose);
}
);
});
}
/// <summary>
/// Become grandchild of self with AppendChild
@ -190,8 +183,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(choose);
choose.AppendChild(when);
when.AppendChild(choose);
}
);
});
}
/// <summary>
/// Become grandchild of self with PrependChild
@ -207,8 +199,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(choose);
choose.AppendChild(when);
when.PrependChild(choose);
}
);
});
}
/// <summary>
/// Become grandchild of self with InsertBeforeChild
@ -226,8 +217,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
choose1.AppendChild(when);
when.PrependChild(choose2);
when.InsertBeforeChild(choose1, choose2);
}
);
});
}
/// <summary>
/// Become grandchild of self with InsertAfterChild
@ -245,8 +235,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
choose1.AppendChild(when);
when.PrependChild(choose2);
when.InsertAfterChild(choose1, choose2);
}
);
});
}
/// <summary>
/// Attempt to reparent with AppendChild
@ -260,8 +249,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target = project.AddTarget("t");
project.AppendChild(target);
}
);
});
}
/// <summary>
/// Attempt to reparent with PrependChild
@ -275,8 +263,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target = project.AddTarget("t");
project.PrependChild(target);
}
);
});
}
/// <summary>
/// Attempt to reparent with InsertBeforeChild
@ -291,8 +278,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target2 = project.AddTarget("t2");
project.InsertBeforeChild(target1, target2);
}
);
});
}
/// <summary>
/// Attempt to reparent with InsertAfterChild
@ -307,8 +293,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target2 = project.AddTarget("t2");
project.InsertAfterChild(target1, target2);
}
);
});
}
/// <summary>
/// Attempt to add to unparented parent with AppendChild
@ -323,8 +308,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = project.CreateTaskElement("tt");
target.AppendChild(task);
}
);
});
}
/// <summary>
/// Attempt to add to unparented parent with PrependChild
@ -339,8 +323,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = project.CreateTaskElement("tt");
target.PrependChild(task);
}
);
});
}
/// <summary>
/// Attempt to add to unparented parent with InsertBeforeChild
@ -356,8 +339,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task2 = project.CreateTaskElement("tt");
target.InsertBeforeChild(task2, task1);
}
);
});
}
/// <summary>
/// Attempt to add to unparented parent with InsertAfterChild
@ -373,8 +355,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task2 = project.CreateTaskElement("tt");
target.InsertAfterChild(task2, task1);
}
);
});
}
/// <summary>
/// Setting attributes on a target should be reflected in the XML
@ -652,8 +633,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTargetElement target = project.CreateTargetElement("t");
target.AppendChild(project);
}
);
});
}
/// <summary>
/// Attempt to insert item in target
@ -669,8 +649,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(target);
target.AppendChild(item);
}
);
});
}
/// <summary>
/// Attempt to insert item without include in itemgroup in project
@ -686,8 +665,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(itemGroup);
itemGroup.AppendChild(item);
}
);
});
}
/// <summary>
/// Add item without include in itemgroup in target
@ -1014,7 +992,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
}
}
[Theory(Skip= "https://github.com/dotnet/msbuild/issues/1253")]
[Theory(Skip = "https://github.com/dotnet/msbuild/issues/1253")]
[MemberData(nameof(InsertMetadataAttributeAfterSiblingsTestData))]
public void InsertMetadataAttributeAfterSiblings(AddMetadata addMetadata, int position, string expectedItem)
{
@ -1078,7 +1056,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
}
}
[Theory(Skip= "https://github.com/dotnet/msbuild/issues/1253")]
[Theory(Skip = "https://github.com/dotnet/msbuild/issues/1253")]
[MemberData(nameof(InsertMetadataAttributeBeforeSiblingsTestData))]
public void InsertMetadataAttributeBeforeSiblings(AddMetadata addMetadata, int position, string expectedItem)
{
@ -1216,8 +1194,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project = ProjectRootElement.Create();
ProjectTargetElement target = project.CreateTargetElement("t");
project.RemoveChild(target);
}
);
});
}
/// <summary>
/// Attempt to remove a child that is parented by something in another project
@ -1232,8 +1209,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project2 = ProjectRootElement.Create();
project2.RemoveChild(target);
}
);
});
}
/// <summary>
/// Attempt to remove a child that is parented by something else in the same project
@ -1250,8 +1226,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
itemGroup1.AppendChild(item);
itemGroup2.RemoveChild(item);
}
);
});
}
/// <summary>
/// Attempt to add an Otherwise before a When
@ -1269,8 +1244,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(choose);
choose.AppendChild(when);
choose.InsertBeforeChild(otherwise, when);
}
);
});
}
/// <summary>
/// Attempt to add an Otherwise after another
@ -1286,8 +1260,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
choose.AppendChild(project.CreateWhenElement("c"));
choose.AppendChild(project.CreateOtherwiseElement());
choose.AppendChild(project.CreateOtherwiseElement());
}
);
});
}
/// <summary>
/// Attempt to add an Otherwise before another
@ -1303,8 +1276,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
choose.AppendChild(project.CreateWhenElement("c"));
choose.AppendChild(project.CreateOtherwiseElement());
choose.InsertAfterChild(project.CreateOtherwiseElement(), choose.FirstChild);
}
);
});
}
/// <summary>
/// Attempt to add a When after an Otherwise
@ -1322,8 +1294,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
project.AppendChild(choose);
choose.AppendChild(otherwise);
choose.InsertAfterChild(when, otherwise);
}
);
});
}
/// <summary>
/// Add When before Otherwise
@ -2287,8 +2258,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectRootElement project = ProjectRootElement.Create();
project.AddProperty("MSBuildToolsPATH", "v");
}
);
});
}
/// <summary>
/// Attempt to add a property with an illegal name
@ -2300,8 +2270,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectRootElement project = ProjectRootElement.Create();
project.AddProperty("ItemGroup", "v");
}
);
});
}
/// <summary>
/// Attempt to add a property with an invalid XML name
@ -2313,8 +2282,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectRootElement project = ProjectRootElement.Create();
project.AddProperty("@#$@#", "v");
}
);
});
}
/// <summary>
/// Too much nesting should not cause stack overflow.

Просмотреть файл

@ -1,12 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System;
using Microsoft.Build.Construction;
using System.Collections.Generic;
using System.Reflection;
using Xunit;
using Microsoft.Build.Construction;
using Shouldly;
using Xunit;
#nullable disable

Просмотреть файл

@ -1,17 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Microsoft.Build.Evaluation;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -37,8 +35,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with unexpected Condition attribute.
@ -56,8 +53,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with unexpected child
@ -76,8 +72,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with a When containing no Condition attribute
@ -101,8 +96,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with only an otherwise
@ -121,8 +115,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with two otherwises
@ -142,8 +135,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read choose with otherwise before when
@ -163,8 +155,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read empty choose
@ -187,8 +178,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectChooseElement choose = (ProjectChooseElement)Helpers.GetFirst(project.Children);
Assert.Null(Helpers.GetFirst(choose.Children));
}
);
});
}
/// <summary>
/// Read choose with only a when
@ -260,8 +250,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
content += @"</Project>";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Setting a When's condition should dirty the project

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -53,8 +52,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read project with more than one ProjectExtensions
@ -73,8 +71,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Set valid content
@ -102,8 +99,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectExtensionsElement extensions = GetEmptyProjectExtensions();
extensions.Content = null;
}
);
});
}
/// <summary>
/// Delete by ID

Просмотреть файл

@ -1,13 +1,16 @@
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.UnitTests;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests;
using Xunit;
using Xunit.Abstractions;
@ -267,7 +270,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
var itemToRemove = project.GetItems("Compile").Single(item => item.EvaluatedInclude == "Class2.cs");
project.RemoveItem(itemToRemove);
StringWriter writer = new StringWriter();
project.Save(writer);
@ -303,7 +306,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
var itemToEdit = project.GetItems("Compile").Single(item => item.EvaluatedInclude == "Class2.cs");
itemToEdit.SetMetadataValue("ExcludeFromStyleCop", "true");
StringWriter writer = new StringWriter();
project.Save(writer);
@ -351,13 +354,13 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
VerifyAssertLineByLine(expected, actual);
}
void VerifyFormattingPreserved(string projectContents)
private void VerifyFormattingPreserved(string projectContents)
{
VerifyFormattingPreservedFromString(projectContents);
VerifyFormattingPreservedFromFile(projectContents);
}
void VerifyFormattingPreservedFromString(string projectContents)
private void VerifyFormattingPreservedFromString(string projectContents)
{
ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(projectContents)),
ProjectCollection.GlobalProjectCollection,
@ -373,7 +376,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
VerifyAssertLineByLine(expected, actual);
}
void VerifyFormattingPreservedFromFile(string projectContents)
private void VerifyFormattingPreservedFromFile(string projectContents)
{
string directory = null;
@ -403,13 +406,13 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
}
}
void VerifyProjectReformatting(string originalContents, string expectedContents)
private void VerifyProjectReformatting(string originalContents, string expectedContents)
{
VerifyProjectReformattingFromString(originalContents, expectedContents);
VerifyProjectReformattingFromFile(originalContents, expectedContents);
}
void VerifyProjectReformattingFromString(string originalContents, string expectedContents)
private void VerifyProjectReformattingFromString(string originalContents, string expectedContents)
{
ProjectRootElement xml = ProjectRootElement.Create(XmlReader.Create(new StringReader(originalContents)),
ProjectCollection.GlobalProjectCollection,
@ -425,7 +428,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
VerifyAssertLineByLine(expected, actual);
}
void VerifyProjectReformattingFromFile(string originalContents, string expectedContents)
private void VerifyProjectReformattingFromFile(string originalContents, string expectedContents)
{
string directory = null;
@ -455,7 +458,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
}
}
void VerifyAssertLineByLine(string expected, string actual)
private void VerifyAssertLineByLine(string expected, string actual)
{
Helpers.VerifyAssertLineByLine(expected, actual, false, _testOutput);
}
@ -503,8 +506,8 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
Project project = new Project();
project.AddItem("ProjectReference", @"..\CLREXE\CLREXE.vcxproj",
new[] {new KeyValuePair<string, string>("metadata", "value")});
new[] { new KeyValuePair<string, string>("metadata", "value") });
StringWriter writer = new EncodingStringWriter();
project.Save(writer);
@ -653,7 +656,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests.Construction
content += @"<Project><Target Name=""Build""/></Project>";
content = ObjectModelHelpers.CleanupFileContents(content);
var file = FileUtilities.GetTemporaryFile(".proj");
var file = FileUtilities.GetTemporaryFileName(".proj");
try
{
File.WriteAllText(file, content, new UTF8Encoding(encoderShouldEmitUTF8Identifier: byteOrderMark));

Просмотреть файл

@ -1,17 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Shared;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -48,8 +46,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read import with empty project attribute
@ -66,8 +63,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read import with unexpected attribute
@ -84,8 +80,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read basic valid imports
@ -149,8 +144,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectImportElement import = (ProjectImportElement)Helpers.GetFirst(project.Children);
import.Project = String.Empty;
}
);
});
}
/// <summary>
/// Setting the project attribute should dirty the project
@ -163,23 +157,21 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
file1 = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file1 = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
ProjectRootElement importProject1 = ProjectRootElement.Create();
importProject1.AddProperty("p", "v1");
importProject1.Save(file1);
file2 = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file2 = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
ProjectRootElement importProject2 = ProjectRootElement.Create();
importProject2.AddProperty("p", "v2");
importProject2.Save(file2);
string content = String.Format
(
string content = String.Format(
@"<Project>
<Import Project='{0}'/>
</Project>",
file1
);
file1);
Project project = new Project(XmlReader.Create(new StringReader(content)));
ProjectImportElement import = Helpers.GetFirst(project.Xml.Imports);
@ -208,18 +200,16 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
ProjectRootElement importProject = ProjectRootElement.Create();
importProject.AddProperty("p", "v1");
importProject.Save(file);
string content = String.Format
(
string content = String.Format(
@"<Project>
<Import Project='{0}'/>
</Project>",
file
);
file);
Project project = new Project(XmlReader.Create(new StringReader(content)));
ProjectImportElement import = Helpers.GetFirst(project.Xml.Imports);
@ -247,15 +237,13 @@ namespace Microsoft.Build.UnitTests.OM.Construction
string testTempPath = Path.Combine(tempPath, "UnitTestsPublicOm");
string projectfile = Path.Combine(testTempPath, "a.proj");
string targetsFile = Path.Combine(tempPath, "x.targets");
string projectfileContent = String.Format
(
string projectfileContent = String.Format(
@"
<Project>
<Import Project='{0}'/>
</Project>
",
testTempPath + "\\..\\x.targets"
);
testTempPath + "\\..\\x.targets");
string targetsfileContent = @"
<Project>
</Project>

Просмотреть файл

@ -1,14 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -184,8 +183,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Checks that an InvalidProjectFileException is thrown when an invalid
@ -205,8 +203,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Checks that an InvalidProjectFileException is thrown when an ImportGroup is placed
@ -226,8 +223,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read import group with unexpected attribute
@ -244,8 +240,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read basic valid import group
@ -358,8 +353,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectImportElement import = (ProjectImportElement)Helpers.GetFirst(importGroup.Imports);
import.Project = String.Empty;
}
);
});
}
/// <summary>
/// Set the condition value

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,13 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -44,8 +42,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read itemdefinitiongroup with no children

Просмотреть файл

@ -1,16 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Linq;
using System.Xml;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Microsoft.Build.Evaluation;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -110,8 +108,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -139,8 +136,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -168,8 +164,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -197,8 +192,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -217,8 +211,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
var exception =
Assert.Throws<InvalidProjectFileException>(
() => { ProjectRootElement.Create(XmlReader.Create(new StringReader(project))); }
);
() => { ProjectRootElement.Create(XmlReader.Create(new StringReader(project))); });
Assert.Contains("Items that are outside Target elements must have one of the following operations: Include, Update, or Remove.", exception.Message);
}
@ -241,8 +234,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
var exception =
Assert.Throws<InvalidProjectFileException>(
() => { ProjectRootElement.Create(XmlReader.Create(new StringReader(project))); }
);
() => { ProjectRootElement.Create(XmlReader.Create(new StringReader(project))); });
Assert.Contains("The attribute \"Exclude\" in element <i> is unrecognized.", exception.Message);
}
@ -285,8 +277,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -428,8 +419,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
[Theory]
@ -454,8 +444,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
[Theory]
@ -480,8 +469,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -513,8 +501,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -542,8 +529,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -571,8 +557,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(project)));
}
);
});
}
/// <summary>
@ -732,8 +717,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Remove = "i1";
}
);
});
}
/// <summary>
@ -749,8 +733,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Update = "i1";
}
);
});
}
/// <summary>
@ -811,8 +794,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Include = "i1";
}
);
});
}
/// <summary>
@ -828,8 +810,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Exclude = "i1";
}
);
});
}
/// <summary>
@ -845,8 +826,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Update = "i1";
}
);
});
}
///
@ -908,8 +888,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Include = "i1";
}
);
});
}
/// <summary>
@ -925,8 +904,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectItemElement item = GetItemFromContent(project);
item.Exclude = "i1";
}
);
});
}
/// <summary>

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,16 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Linq;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using System.Linq;
using Microsoft.Build.Evaluation;
using Xunit;
using Xunit.Abstractions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -60,8 +59,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read metadatum with invalid name characters (but legal xml)
@ -82,8 +80,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
[Theory]
@ -106,8 +103,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
@ -129,8 +125,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
[Theory]
@ -153,8 +148,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
@ -176,8 +170,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
@ -203,8 +196,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
@ -257,8 +249,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectMetadataElement metadatum = GetMetadataXml();
metadatum.Name = "ImportGroup";
}
);
});
}
[Fact]
@ -270,8 +261,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
metadatum.Name = "Include";
}
);
});
}
@ -284,8 +274,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
metadatum.ExpressedAsAttribute = true;
}
);
});
}
[Theory]
@ -371,8 +360,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectMetadataElement metadatum = GetMetadataXml();
metadatum.Value = null;
}
);
});
}
/// <summary>
/// Read a metadatum containing an expression like @(..) but whose parent is an ItemDefinitionGroup
@ -393,8 +381,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read a metadatum containing an expression like @(..) but whose parent is NOT an ItemDefinitionGroup
@ -1259,7 +1246,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
return metadata;
}
void VerifyAssertLineByLine(string expected, string actual)
private void VerifyAssertLineByLine(string expected, string actual)
{
Helpers.VerifyAssertLineByLine(expected, actual, false, _testOutput);
}

Просмотреть файл

@ -1,14 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -83,8 +81,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children);
Assert.Equal(String.Empty, onError.ExecuteTargetsAttribute);
}
);
});
}
/// <summary>
/// Read onerror with empty executetargets attribute
@ -110,8 +107,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOnErrorElement onError = (ProjectOnErrorElement)Helpers.GetFirst(target.Children);
Assert.Equal(String.Empty, onError.ExecuteTargetsAttribute);
}
);
});
}
/// <summary>
/// Read onerror with invalid attribute
@ -130,8 +126,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read onerror with invalid child element
@ -152,8 +147,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read onerror before task
@ -173,8 +167,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read onerror before task
@ -194,8 +187,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read onerror before task
@ -215,8 +207,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Set ExecuteTargets
@ -242,8 +233,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOnErrorElement onError = GetOnError();
onError.ExecuteTargetsAttribute = null;
}
);
});
}
/// <summary>
/// Set ExecuteTargets to empty string
@ -256,8 +246,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOnErrorElement onError = GetOnError();
onError.ExecuteTargetsAttribute = String.Empty;
}
);
});
}
/// <summary>
/// Set on error condition

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -68,8 +67,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with reserved property name
@ -91,8 +89,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with missing taskparameter
@ -114,8 +111,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with missing taskparameter
@ -137,8 +133,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with child element
@ -162,8 +157,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with propertyname but an empty itemname attribute
@ -185,8 +179,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an output property with an itemname but an empty propertyname attribute
@ -208,8 +201,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Modify the condition
@ -250,8 +242,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOutputElement output = GetOutputProperty();
output.ItemType = "i1b";
}
);
});
}
/// <summary>
/// Set the item name value
@ -278,8 +269,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectOutputElement output = GetOutputItem();
output.PropertyName = "p1b";
}
);
});
}
/// <summary>
/// Helper to get a ProjectOutputElement for an output item

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -70,8 +69,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read property with invalid reserved name
@ -90,8 +88,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read property with invalid built in name
@ -110,8 +107,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read property with invalid attribute
@ -130,8 +126,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read property with child element
@ -152,8 +147,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Set property value
@ -223,8 +217,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectPropertyElement property = GetPropertyXml();
property.Name = "ImportGroup";
}
);
});
}
/// <summary>
/// Set property value to empty
@ -251,8 +244,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectPropertyElement property = GetPropertyXml();
property.Value = null;
}
);
});
}
/// <summary>
/// Set condition

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -22,6 +22,7 @@ using ProjectCollection = Microsoft.Build.Evaluation.ProjectCollection;
using Shouldly;
using Xunit;
using Microsoft.Build.Framework;
using Xunit.NetCore.Extensions;
#nullable disable
@ -172,7 +173,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
public void ConstructOverSameFileReturnsSame()
{
ProjectRootElement projectXml1 = ProjectRootElement.Create();
projectXml1.Save(FileUtilities.GetTemporaryFile());
projectXml1.Save(FileUtilities.GetTemporaryFileName());
ProjectRootElement projectXml2 = ProjectRootElement.Open(projectXml1.FullPath);
@ -267,8 +268,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
Assert.Throws<InvalidProjectFileException>(() =>
{
ProjectRootElement.Create(XmlReader.Create(new StringReader("XXX")));
}
);
});
}
/// <summary>
@ -297,8 +297,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Valid Xml, invalid syntax below the root
@ -315,8 +314,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Root indicates upgrade needed
@ -331,8 +329,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Valid Xml, invalid namespace below the root
@ -349,8 +346,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Tests that the namespace error reports are correct
@ -403,8 +399,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Valid Xml, invalid syntax, should not get added to the Xml cache and
@ -429,7 +424,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
try
{
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
File.WriteAllText(path, content);
ProjectRootElement.Open(path);
@ -445,8 +440,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
File.Delete(path);
}
}
);
});
}
/// <summary>
/// Verify that opening project using XmlTextReader does not add it to the Xml cache
@ -462,7 +456,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
File.WriteAllText(path, content);
var reader1 = XmlReader.Create(path);
@ -499,7 +493,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
File.WriteAllText(path, content);
ProjectRootElement root1 = ProjectRootElement.Create(path);
@ -561,8 +555,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project = ProjectRootElement.Create(reader);
project.Save();
}
);
});
}
/// <summary>
/// Save content with transforms.
@ -605,7 +598,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
file = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
project.Save(file);
@ -697,8 +690,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectRootElement project = ProjectRootElement.Create();
project.Save();
}
);
});
}
/// <summary>
/// Verifies that the ProjectRootElement.Encoding property getter returns values
@ -730,7 +722,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
[Fact]
public void EncodingGetterBasedOnActualEncodingWhenXmlDeclarationIsAbsent()
{
string projectFullPath = FileUtilities.GetTemporaryFile();
string projectFullPath = FileUtilities.GetTemporaryFileName();
try
{
VerifyLoadedProjectHasEncoding(projectFullPath, Encoding.UTF8);
@ -892,11 +884,9 @@ namespace Microsoft.Build.UnitTests.OM.Construction
#if FEATURE_SECURITY_PRINCIPAL_WINDOWS
/// <summary>
/// Build a solution file that can't be accessed
/// Build a solution file that can't be accessed.
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // Security classes are not supported on Unix
[WindowsOnlyFact(additionalMessage: "Security classes are not supported on Unix.")]
public void SolutionCanNotBeOpened()
{
Assert.Throws<InvalidProjectFileException>(() =>
@ -935,16 +925,13 @@ namespace Microsoft.Build.UnitTests.OM.Construction
File.Delete(tempFileSentinel);
Assert.False(File.Exists(solutionFile));
}
}
);
});
}
/// <summary>
/// Build a project file that can't be accessed
/// Build a project file that can't be accessed.
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
// FileSecurity class is not supported on Unix
[WindowsOnlyFact(additionalMessage: "FileSecurity class is not supported on Unix.")]
public void ProjectCanNotBeOpened()
{
Assert.Throws<InvalidProjectFileException>(() =>
@ -979,8 +966,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
File.Delete(projectFile);
Assert.False(File.Exists(projectFile));
}
}
);
});
}
#endif
@ -996,7 +982,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
try
{
solutionFile = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
solutionFile = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
// Arbitrary corrupt content
string content = @"Microsoft Visual Studio Solution File, Format Version 10.00
@ -1011,14 +997,12 @@ Project(""{";
{
File.Delete(solutionFile);
}
}
);
});
}
/// <summary>
/// Open lots of projects concurrently to try to trigger problems
/// </summary>
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // This test is platform specific for Windows
[WindowsOnlyFact]
public void ConcurrentProjectOpenAndCloseThroughProject()
{
int iterations = 500;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
@ -32,8 +32,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectRootElement project = ProjectRootElement.Create();
project.CreateTargetElement("@#$invalid@#$");
}
);
});
}
/// <summary>
/// Read targets in an empty project
@ -107,8 +106,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectTargetElement target = GetTargetXml();
target.Inputs = null;
}
);
});
}
/// <summary>
/// Set null outputs on the target element
@ -120,8 +118,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectTargetElement target = GetTargetXml();
target.Outputs = null;
}
);
});
}
/// <summary>
/// Set null dependsOnTargets on the target element
@ -133,8 +130,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectTargetElement target = GetTargetXml();
target.DependsOnTargets = null;
}
);
});
}
/// <summary>
/// Set null dependsOnTargets on the target element
@ -146,8 +142,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
ProjectTargetElement target = GetTargetXml();
target.KeepDuplicateOutputs = null;
}
);
});
}
/// <summary>
/// Set null condition on the target element
@ -176,8 +171,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read a target with an invalid attribute
@ -194,8 +188,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read an target with two task children

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -97,8 +96,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
GetTaskFromContent(content);
}
);
});
}
/// <summary>
/// Read task with empty parameter.
@ -176,8 +174,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = GetBasicTask();
task.SetParameter("p1", null);
}
);
});
}
/// <summary>
/// Set a parameter with the reserved name 'continueonerror'
@ -190,8 +187,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = GetBasicTask();
task.SetParameter("ContinueOnError", "v");
}
);
});
}
/// <summary>
/// Set a parameter with the reserved name 'condition'
@ -204,8 +200,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = GetBasicTask();
task.SetParameter("Condition", "c");
}
);
});
}
/// <summary>
/// Set a parameter using a null name
@ -218,8 +213,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectTaskElement task = GetBasicTask();
task.SetParameter(null, "v1");
}
);
});
}
/// <summary>
/// Add a parameter to the task

Просмотреть файл

@ -1,14 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -45,8 +43,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with empty task name attribute
@ -63,8 +60,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with unexpected attribute
@ -81,8 +77,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with neither AssemblyFile nor AssemblyName attributes
@ -99,8 +94,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with only empty AssemblyFile attribute
@ -117,8 +111,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with empty AssemblyFile attribute but AssemblyName present
@ -135,8 +128,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with only empty AssemblyName attribute but AssemblyFile present
@ -153,8 +145,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with both AssemblyName and AssemblyFile attributes
@ -171,8 +162,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with both AssemblyName and AssemblyFile attributes but both are empty
@ -189,8 +179,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Read usingtask with assembly file
@ -290,8 +279,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectUsingTaskElement usingTask = GetUsingTaskAssemblyName();
usingTask.AssemblyFile = "afb";
}
);
});
}
/// <summary>
/// Set assembly name on a usingtask that already has assembly file
@ -304,8 +292,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectUsingTaskElement usingTask = GetUsingTaskAssemblyFile();
usingTask.AssemblyName = "anb";
}
);
});
}
/// <summary>
/// Set task name
@ -370,8 +357,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Make sure there is an exception when there are multiple task groups in the using task tag.
@ -391,8 +377,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Make sure there is an exception when there is an unknown child
@ -411,8 +396,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Make sure there is an no exception when there are children in the using task
@ -460,8 +444,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Helpers.GetFirst(project.Children);
Assert.True(false);
}
);
});
}
/// <summary>
/// Make sure there is an exception when a parameter group is added but no task factory attribute is on the using task
@ -482,8 +465,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement project = ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Helpers.GetFirst(project.Children);
Assert.True(false);
}
);
});
}
/// <summary>
/// Helper to get a ProjectUsingTaskElement with a task factory, required runtime and required platform

Просмотреть файл

@ -1,15 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Microsoft.Build.Construction;
using Microsoft.Build.Shared;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Shared;
using Shouldly;
using Xunit;
using System.Text;
#nullable disable
@ -53,8 +53,7 @@ namespace Microsoft.Build.UnitTests.Construction
ParseSolutionHelper(solutionFileContents);
Assert.True(false, "Should not get here");
}
);
});
}
/// <summary>
/// Test that a project with the C++ project guid and an arbitrary extension is seen as valid --
@ -219,8 +218,7 @@ namespace Microsoft.Build.UnitTests.Construction
";
ParseSolutionHelper(solutionFileContents);
}
);
});
}
/// <summary>
/// Expected version numbers less than 7 to cause an invalid project file exception.
@ -237,8 +235,7 @@ namespace Microsoft.Build.UnitTests.Construction
";
ParseSolutionHelper(solutionFileContents);
}
);
});
}
/// <summary>
/// Test to parse a very basic .sln file to validate that description property in a solution file
@ -788,8 +785,7 @@ namespace Microsoft.Build.UnitTests.Construction
";
ParseSolutionHelper(solutionFileContents);
}
);
});
}
/// <summary>
/// Test some invalid cases for solution configuration parsing
@ -815,8 +811,7 @@ namespace Microsoft.Build.UnitTests.Construction
";
ParseSolutionHelper(solutionFileContents);
}
);
});
}
/// <summary>
/// Test some invalid cases for solution configuration parsing
@ -842,8 +837,7 @@ namespace Microsoft.Build.UnitTests.Construction
";
ParseSolutionHelper(solutionFileContents);
}
);
});
}
/// <summary>
/// Make sure the project configurations in solution configurations get parsed correctly
@ -1064,7 +1058,7 @@ namespace Microsoft.Build.UnitTests.Construction
private static SolutionFile ParseSolutionHelper(string solutionFileContents)
{
solutionFileContents = solutionFileContents.Replace('\'', '"');
string solutionPath = FileUtilities.GetTemporaryFile(".sln");
string solutionPath = FileUtilities.GetTemporaryFileName(".sln");
try
{

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -48,8 +47,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Create a task body outside of a using task
@ -68,8 +66,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
";
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Set body value
@ -110,8 +107,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectUsingTaskBodyElement body = GetBodyXml();
body.TaskBody = null;
Assert.True(false);
}
);
});
}
/// <summary>
/// Verify setting the value of evaluate to null will wipe out the element and then the property will return true by default.

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -92,8 +91,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Set type value

Просмотреть файл

@ -1,13 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using System.Xml;
using Microsoft.Build.Construction;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -109,8 +108,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
{
GetParameterGroupXml(s_contentDuplicateParameters);
Assert.True(false);
}
);
});
}
/// <summary>
/// Read parameterGroup with a attribute
@ -130,8 +128,7 @@ namespace Microsoft.Build.UnitTests.OM.Construction
ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
Assert.True(false);
}
);
});
}
/// <summary>
/// Helper to get a UsingTaskParameterGroupElement from xml

Просмотреть файл

@ -1,15 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.IO;
using Microsoft.Build.Construction;
using Xunit;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Shared;
using Xunit;
#nullable disable
@ -462,7 +461,7 @@ multi-line comment here
// Using streams can cause issues with CRLF characters being replaced by LF going in to
// ProjectRootElement. Saving to disk mimics the real-world behavior so we can specifically
// test issues with CRLF characters being normalized. Related issue: #1340
var file = FileUtilities.GetTemporaryFile();
var file = FileUtilities.GetTemporaryFileName();
var expected = ObjectModelHelpers.CleanupFileContents(updatedProject);
string actual;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -232,8 +232,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project();
project.AddItem("i", String.Empty);
}
);
});
}
/// <summary>
/// Add an item with null metadata parameter.
@ -528,8 +527,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItemElement item2 =
project.AddItem(
"i",
NativeMethodsShared.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")
[0].Xml;
NativeMethodsShared.IsWindows ? @"c:\subdir1\a\b\subdir2\c\i1.xyx" : "/subdir1/a/b/subdir2/c/i1.xyx")[
0].Xml;
string expected = ObjectModelHelpers.CleanupFileContents(
NativeMethodsShared.IsWindows ?
@ -1156,7 +1155,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[MemberData(nameof(ItemElementsWithGlobsThatRequireSplitting))]
public void RenameThrowsWhenItemElementSplittingIsDisabled(string projectContents, int itemIndex, SetupProject setupProject)
{
AssertDisabledItemSplitting(projectContents, itemIndex, setupProject, (p, i) => {i.Rename("foo"); });
AssertDisabledItemSplitting(projectContents, itemIndex, setupProject, (p, i) => { i.Rename("foo"); });
}
/// <summary>
@ -1457,7 +1456,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[MemberData(nameof(ItemElementsWithGlobsThatRequireSplitting))]
public void RemoveItemsThrowsWhenItemElementSplittingIsDisabled(string projectContents, int itemIndex, SetupProject setupProject)
{
AssertDisabledItemSplitting(projectContents, itemIndex, setupProject, (p, i) => { p.RemoveItems(new [] {i}); });
AssertDisabledItemSplitting(projectContents, itemIndex, setupProject, (p, i) => { p.RemoveItems(new[] { i }); });
}
/// <summary>
@ -1589,8 +1588,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var property = project.SetProperty("p", "v1");
property.Xml.Parent.RemoveAllChildren();
property.UnevaluatedValue = "v2";
}
);
});
}
/// <summary>
/// Setting an evaluated property after its XML's parent has been removed should
@ -1605,8 +1603,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var property = project.SetProperty("p", "v1");
property.Xml.Parent.Parent.RemoveAllChildren();
property.UnevaluatedValue = "v2";
}
);
});
}
/// <summary>
/// Setting an evaluated metadatum after its XML has been removed should
@ -1621,8 +1618,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var metadatum = project.AddItem("i", "i1")[0].SetMetadataValue("p", "v1");
metadatum.Xml.Parent.RemoveAllChildren();
metadatum.UnevaluatedValue = "v2";
}
);
});
}
/// <summary>
/// Changing an item's type after its XML has been removed should
@ -1637,8 +1633,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var item = project.AddItem("i", "i1")[0];
item.Xml.Parent.RemoveAllChildren();
item.ItemType = "j";
}
);
});
}
/// <summary>
/// Changing an item's type after its XML has been removed should
@ -1653,8 +1648,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var item = project.AddItem("i", "i1")[0];
item.Xml.Parent.RemoveAllChildren();
item.RemoveMetadata("m");
}
);
});
}
[Theory]
@ -1678,8 +1672,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
new[] // files that should be captured by the glob
{
"a.foo"
}
)]
})]
// explode on item coming from glob that expands to multiple items
[InlineData(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
@ -1694,8 +1687,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
"a.foo",
"b.foo"
}
)]
})]
public void RemoveMetadataThrowsWhenItemElementSplittingIsDisabledAndItemComesFromGlob(string projectContents, int itemIndex, string[] files)
{
using (var env = TestEnvironment.Create())
@ -1730,8 +1722,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var metadatum = project.AddItem("i", "i1")[0].SetMetadataValue("p", "v1");
metadatum.Xml.Parent.Parent.RemoveAllChildren();
metadatum.UnevaluatedValue = "v2";
}
);
});
}
/// <summary>
/// Setting an evaluated metadatum after its XML's parent's parent has been removed should
@ -1746,8 +1737,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var metadatum = project.AddItem("i", "i1")[0].SetMetadataValue("p", "v1");
metadatum.Xml.Parent.Parent.Parent.RemoveAllChildren();
metadatum.UnevaluatedValue = "v2";
}
);
});
}
[Theory]
@ -2161,8 +2151,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project();
project.AddItemFast("i", String.Empty);
}
);
});
}
/// <summary>
/// Add an item with null metadata parameter.

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;

Просмотреть файл

@ -1,20 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Shared;
using Microsoft.Build.Utilities;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Shouldly;
using Xunit;
using Xunit.Abstractions;
using Shouldly;
using System.Reflection;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -63,7 +63,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
ProjectRootElement xml = ProjectRootElement.Create(path);
xml.Save();
@ -95,7 +95,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project();
Assert.Equal(0, ProjectCollection.GlobalProjectCollection.Count);
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
project.Save(path);
Project project2 = ProjectCollection.GlobalProjectCollection.LoadProject(path);
@ -124,7 +124,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectCollection collection = new ProjectCollection();
Project project = new Project(collection);
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
project.Save(path);
Project project2 = collection.LoadProject(path);
@ -132,7 +132,10 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
finally
{
if (path != null) File.Delete(path);
if (path != null)
{
File.Delete(path);
}
}
}
@ -293,7 +296,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
ProjectRootElement xml = ProjectRootElement.Create();
xml.Save(path);
Assert.Equal(0, ProjectCollection.GlobalProjectCollection.Count);
@ -337,7 +340,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
ProjectRootElement.Create(path).Save();
ProjectCollection collection1 = new ProjectCollection();
@ -769,8 +772,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Console.WriteLine(ex.Message);
throw;
}
}
);
});
}
/// <summary>
@ -823,8 +825,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file1 = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file1 = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
Project project = new Project();
project.Save(file1);
@ -838,8 +840,15 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
finally
{
if (file1 != null) File.Delete(file1);
if (file2 != null) File.Delete(file2);
if (file1 != null)
{
File.Delete(file1);
}
if (file2 != null)
{
File.Delete(file2);
}
}
}
@ -855,8 +864,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file1 = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file1 = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
var project = new Project();
project.Save(file1);
@ -874,8 +883,15 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
finally
{
if (file1 != null) File.Delete(file1);
if (file2 != null) File.Delete(file2);
if (file1 != null)
{
File.Delete(file1);
}
if (file2 != null)
{
File.Delete(file2);
}
}
}
@ -891,8 +907,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file1 = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file1 = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
var project = new Project();
project.Save(file1);
@ -910,8 +926,15 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
finally
{
if (file1 != null) File.Delete(file1);
if (file2 != null) File.Delete(file2);
if (file1 != null)
{
File.Delete(file1);
}
if (file2 != null)
{
File.Delete(file2);
}
}
}
@ -1073,7 +1096,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
#else
[Fact(Skip = "https://github.com/dotnet/msbuild/issues/276")]
#endif
[Trait("Category", "mono-osx-failing")]
public void DefaultToolsVersion2()
{
if (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version20) != null)
@ -1433,7 +1455,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
private static string CreateProjectFile()
{
ProjectRootElement xml = ProjectRootElement.Create();
string path = FileUtilities.GetTemporaryFile();
string path = FileUtilities.GetTemporaryFileName();
xml.Save(path);
return path;
}

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -8,11 +8,11 @@ using System.Linq;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Xunit;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -139,8 +139,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
File.Delete(file);
}
}
);
});
}
/// <summary>
/// Attempt to add new metadata on imported item definition should succeed,
@ -166,8 +165,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItemDefinition definition = project.ItemDefinitions["i"];
definition.SetMetadataValue("n", "n0");
string expected = String.Format
(
string expected = String.Format(
ObjectModelHelpers.CleanupFileContents(
@"<Project ToolsVersion=""msbuilddefaulttoolsversion"" xmlns=""msbuildnamespace"">
<ItemDefinitionGroup>
@ -177,8 +175,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
</ItemDefinitionGroup>
<Import Project=""{0}"" />
</Project>"),
file
);
file);
Helpers.VerifyAssertProjectContent(expected, project.Xml);
}
@ -477,8 +474,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -500,8 +496,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -523,8 +518,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -546,8 +540,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -569,8 +562,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -592,8 +584,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -615,8 +606,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Built-in metadata is prohibited in item definition conditions.
@ -638,8 +628,7 @@ ObjectModelHelpers.CleanupFileContents(
</Project>");
Project project = new Project(XmlReader.Create(new StringReader(content)));
}
);
});
}
/// <summary>
/// Custom metadata is allowed in item definition conditions.

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -13,9 +13,11 @@ using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.UnitTests.Shared;
using Shouldly;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using Xunit.NetCore.Extensions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -54,7 +56,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
</Project>
";
protected TestEnvironment _env;
protected readonly TestEnvironment _env;
private DummyMappedDrive _mappedDrive = null;
public ProjectItem_Tests()
{
@ -64,6 +67,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
public void Dispose()
{
_env.Dispose();
_mappedDrive?.Dispose();
}
/// <summary>
@ -231,8 +235,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItem item = GetOneItemFromFragment(@"<i Include='c:\foo\bar.baz'/>");
item.SetMetadataValue("##invalid##", "x");
}
);
});
}
/// <summary>
/// Attempting to set built-in metadata should fail
@ -245,8 +248,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItem item = GetOneItemFromFragment(@"<i Include='c:\foo\bar.baz'/>");
item.SetMetadataValue("FullPath", "x");
}
);
});
}
/// <summary>
/// Attempting to set reserved metadata should fail
@ -259,8 +261,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItem item = GetOneItemFromFragment(@"<i Include='c:\foo\bar.baz'/>");
item.SetMetadataValue("Choose", "x");
}
);
});
}
/// <summary>
/// Metadata enumerator should only return custom metadata
@ -319,7 +320,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
File.WriteAllText(path, String.Empty);
FileInfo info = new FileInfo(path);
@ -706,8 +707,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
TestIncludeExclude(projectContents, inputFiles, expectedInclude, includeString, excludeString, normalizeSlashes: true);
}
[Theory]
[PlatformSpecific(TestPlatforms.Windows)]
[WindowsOnlyTheory]
[InlineData(ItemWithIncludeAndExclude,
@"src/**/*.cs",
new[]
@ -795,23 +795,22 @@ namespace Microsoft.Build.UnitTests.OM.Definition
/// <summary>
/// Project getter that renames an item to a drive enumerating wildcard that results in a logged warning.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[InlineData(@"z:\**\*.log")]
[InlineData(@"z:$(empty)\**\*.log")]
[InlineData(@"z:\**")]
[InlineData(@"z:\\**")]
[InlineData(@"z:\\\\\\\\**")]
[InlineData(@"z:\**\*.cs")]
[WindowsOnlyTheory]
[InlineData(@"%DRIVE%:\**\*.log")]
[InlineData(@"%DRIVE%:$(empty)\**\*.log")]
[InlineData(@"%DRIVE%:\**")]
[InlineData(@"%DRIVE%:\\**")]
[InlineData(@"%DRIVE%:\\\\\\\\**")]
[InlineData(@"%DRIVE%:\**\*.cs")]
public void ProjectGetterResultsInWindowsDriveEnumerationWarning(string unevaluatedInclude)
{
var mappedDrive = GetDummyMappedDrive();
unevaluatedInclude = UpdatePathToMappedDrive(unevaluatedInclude, mappedDrive.MappedDriveLetter);
ProjectGetterResultsInDriveEnumerationWarning(unevaluatedInclude);
}
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
[UnixOnlyTheory]
[ActiveIssue("https://github.com/dotnet/msbuild/issues/8373")]
[InlineData(@"/**/*.log")]
[InlineData(@"$(empty)/**/*.log")]
[InlineData(@"/$(empty)**/*.log")]
@ -837,7 +836,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project(projectCollection);
// Add item
_= project.AddItem("i", unevaluatedInclude);
_ = project.AddItem("i", unevaluatedInclude);
// Verify
collectionLogger.WarningCount.ShouldBe(1);
@ -880,34 +879,56 @@ namespace Microsoft.Build.UnitTests.OM.Definition
/// <summary>
/// Project instance created from a file that contains a drive enumerating wildcard results in a logged warning on the Windows platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
ImportProjectElement,
@"z:\**\*.targets",
@"%DRIVE%:\**\*.targets",
null)]
// LazyItem.IncludeOperation
[InlineData(
ItemWithIncludeAndExclude,
@"z:$(Microsoft_WindowsAzure_EngSys)\**\*",
@"%DRIVE%:$(Microsoft_WindowsAzure_EngSys)\**\*",
@"$(Microsoft_WindowsAzure_EngSys)\*.pdb;$(Microsoft_WindowsAzure_EngSys)\Microsoft.WindowsAzure.Storage.dll;$(Microsoft_WindowsAzure_EngSys)\Certificates\**\*")]
// LazyItem.IncludeOperation for Exclude
[InlineData(
ItemWithIncludeAndExclude,
@"$(EmptyProperty)\*.cs",
@"z:\$(Microsoft_WindowsAzure_EngSys)**")]
@"%DRIVE%:\$(Microsoft_WindowsAzure_EngSys)**")]
public void LogWindowsWarningUponProjectInstanceCreationFromDriveEnumeratingContent(string content, string placeHolder, string excludePlaceHolder = null)
{
var mappedDrive = GetDummyMappedDrive();
placeHolder = UpdatePathToMappedDrive(placeHolder, mappedDrive.MappedDriveLetter);
excludePlaceHolder = UpdatePathToMappedDrive(excludePlaceHolder, mappedDrive.MappedDriveLetter);
content = string.Format(content, placeHolder, excludePlaceHolder);
CleanContentsAndCreateProjectInstanceFromFileWithDriveEnumeratingWildcard(content, false);
}
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
private DummyMappedDrive GetDummyMappedDrive()
{
if (NativeMethods.IsWindows)
{
// let's create the mapped drive only once it's needed by any test, then let's reuse;
_mappedDrive ??= new DummyMappedDrive();
}
return _mappedDrive;
}
private static string UpdatePathToMappedDrive(string path, char driveLetter)
{
const string drivePlaceholder = "%DRIVE%";
// if this seems to be rooted path - replace with the dummy mount
if (!string.IsNullOrEmpty(path) && path.StartsWith(drivePlaceholder))
{
path = driveLetter + path.Substring(drivePlaceholder.Length);
}
return path;
}
[UnixOnlyTheory]
[ActiveIssue("https://github.com/dotnet/msbuild/issues/8373")]
[InlineData(
ImportProjectElement,
@"\**\*.targets",
@ -927,7 +948,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
public void LogWarningUponProjectInstanceCreationFromDriveEnumeratingContent(string content, string placeHolder, string excludePlaceHolder = null)
{
content = string.Format(content, placeHolder, excludePlaceHolder);
CleanContentsAndCreateProjectInstanceFromFileWithDriveEnumeratingWildcard(content, false);
CleanContentsAndCreateProjectInstanceFromFileWithDriveEnumeratingWildcard(content, false);
}
private static void CleanContentsAndCreateProjectInstanceFromFileWithDriveEnumeratingWildcard(string content, bool throwException)
@ -1014,8 +1035,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
@"project\a",
},
false // whether the include survives the exclude (true) or not (false)
)]
false) // whether the include survives the exclude (true) or not (false)
]
// exclude matches include; file is below the project file
[InlineData(ItemWithIncludeAndExclude,
@"a",
@ -1028,8 +1049,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
@"project\dir\a",
},
false
)]
false)]
// exclude matches include; file is above the project file
[InlineData(ItemWithIncludeAndExclude,
@"a",
@ -1042,8 +1062,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
@"a",
},
false
)]
false)]
// exclude does not match include; file is next to project file; exclude points above the project file
[InlineData(ItemWithIncludeAndExclude,
"a",
@ -1056,8 +1075,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
"a",
},
true
)]
true)]
// exclude does not match include; file is below the project file; exclude points next to the project file
[InlineData(ItemWithIncludeAndExclude,
"a",
@ -1070,8 +1088,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
@"project\dir\a",
},
true
)]
true)]
// exclude does not match include; file is above the project file; exclude points next to the project file
[InlineData(ItemWithIncludeAndExclude,
"a",
@ -1084,8 +1101,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
"a",
},
true
)]
true)]
public void IncludeAndExcludeWorkWithRelativeAndAbsolutePaths(
string projectContents,
string includeItem,
@ -1133,26 +1149,24 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[InlineData(
"../a.cs;b.cs", // include string
"**/*.cs", // exclude string
new[] {"a.cs", "ProjectDir/b.cs"}, // files to create relative to the test root dir
new[] { "a.cs", "ProjectDir/b.cs" }, // files to create relative to the test root dir
"ProjectDir", // relative path from test root to project
new[] { "../a.cs" } // expected items
)]
new[] { "../a.cs" }) // expected items
]
// exclude globbing cone below project level;
[InlineData(
"a.cs;a/b.cs",
"a/**/*.cs",
new[] { "a.cs", "a/b.cs" },
"",
new[] { "a.cs" }
)]
new[] { "a.cs" })]
// exclude globbing above project level;
[InlineData(
"a.cs;../b.cs;../../c.cs",
"../**/*.cs",
new[] { "a/ProjectDir/a.cs", "a/b.cs", "c.cs" },
"a/ProjectDir",
new[] { "../../c.cs" }
)]
new[] { "../../c.cs" })]
public void ExcludeWithMissmatchingGlobCones(string includeString, string excludeString, string[] files, string relativePathFromRootToProject, string[] expectedInclude)
{
var projectContents = string.Format(ItemWithIncludeAndExclude, includeString, excludeString);
@ -1171,8 +1185,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
"a.cs", // exclude string
new[] { "ProjectDir/a.cs", "b.cs" }, // files to create relative to the test root dir
"ProjectDir", // relative path from test root to project
new[] { "../b.cs" } // expected items
)]
new[] { "../b.cs" }) // expected items
]
public void ExcludingRelativeItemToCurrentDirectoryShouldWorkWithAboveTheConeIncludes(string includeString, string excludeString, string[] files, string relativePathFromRootToProject, string[] expectedInclude)
{
var projectContents = string.Format(ItemWithIncludeAndExclude, includeString, excludeString);
@ -1642,8 +1656,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
";
GetOneItem(content);
}
);
});
}
/// <summary>
/// Two items should each get their own values for built-in metadata
@ -1924,8 +1937,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectItem item = Helpers.GetFirst(project.GetItems("i"));
item.RemoveMetadata("m"); // Should throw
}
);
});
}
/// <summary>
/// Remove a nonexistent metadatum
@ -1958,8 +1970,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.RemoveMetadata("FullPath");
}
);
});
}
/// <summary>
/// Simple rename
@ -2048,8 +2059,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
project.ReevaluateIfNecessary();
item.ItemType = "|";
}
);
});
}
/// <summary>
/// Attempt to rename imported item should fail
@ -2063,7 +2073,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
Project import = new Project();
import.AddItem("i", "i1");
import.Save(file);
@ -2080,8 +2090,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
File.Delete(file);
}
}
);
});
}
/// <summary>
/// Attempt to set metadata on imported item should fail
@ -2095,7 +2104,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
Project import = new Project();
import.AddItem("i", "i1");
import.Save(file);
@ -2112,8 +2121,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
File.Delete(file);
}
}
);
});
}
/// <summary>
/// Attempt to remove metadata on imported item should fail
@ -2127,7 +2135,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
Project import = new Project();
ProjectItem item = import.AddItem("i", "i1")[0];
item.SetMetadataValue("m", "m0");
@ -2145,8 +2153,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
File.Delete(file);
}
}
);
});
}
[Fact]
@ -2165,7 +2172,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
using (var env = TestEnvironment.Create())
{
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, projectContents, null, null);
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, projectContents);
var metadata = project.GetItems("I").FirstOrDefault().SetMetadataValue("M", "$(P);@(Foo)", true);
@ -2191,7 +2198,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
using (var env = TestEnvironment.Create())
{
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, projectContents, null, null);
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, projectContents);
var item = project.GetItems("I").FirstOrDefault();
var metadata = item.SetMetadataValue("M", "V", true);
@ -2325,8 +2332,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment(
"<i Include='a;b' />" +
"<i Remove='b;c' />"
);
"<i Remove='b;c' />");
Assert.Single(items);
Assert.Equal("a", items[0].EvaluatedInclude);
@ -2338,8 +2344,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment(
"<i Include='a;b' />" +
"<i Include='a;b' />" +
"<i Remove='b;c' />"
);
"<i Remove='b;c' />");
Assert.Equal(2, items.Count);
Assert.Equal(@"a;a", string.Join(";", items.Select(i => i.EvaluatedInclude)));
@ -2350,8 +2355,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment(
@"<i Include='a.txt;b.cs;bin\foo.cs' />" +
@"<i Remove='bin\**' />"
);
@"<i Remove='bin\**' />");
Assert.Equal(2, items.Count);
Assert.Equal(@"a.txt;b.cs", string.Join(";", items.Select(i => i.EvaluatedInclude)));
@ -2363,8 +2367,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
IList<ProjectItem> items = ObjectModelHelpers.GetItemsFromFragment(
@"<i Include='a;b;c;d' />" +
@"<j Include='b;d' />" +
@"<i Remove='@(j)' />"
);
@"<i Remove='@(j)' />");
Assert.Equal(2, items.Count);
Assert.Equal(@"a;c", string.Join(";", items.Select(i => i.EvaluatedInclude)));
@ -2393,8 +2396,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
var projectContents = ObjectModelHelpers.FormatProjectContentsWithItemGroupFragment(
@"<i Include='a;b;c' />" +
@"<i Condition='0 == 1' Remove='b' />" +
@"<i Condition='1 == 1' Remove='c' />"
);
@"<i Condition='1 == 1' Remove='c' />");
var project = ObjectModelHelpers.CreateInMemoryProject(projectContents);
@ -2411,8 +2413,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
@"<i Include='a;b;c;d' />" +
@"<i Condition='0 == 1' Remove='b' />" +
@"<i Condition='1 == 1' Remove='c' />" +
@"<i Remove='d' />"
);
@"<i Remove='d' />");
var project = ObjectModelHelpers.CreateInMemoryProject(projectContents);
@ -2482,7 +2483,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
<I1 Include='c1' M1='foo/bar.vb' M2='y'/>
<I1 Include='d1' M1='foo\foo\foo' M2='b'/>
<I1 Include='e1' M1='a/b/../c/./d' M2='1'/>
<I1 Include='f1' M1='{ Environment.CurrentDirectory }\b\c' M2='6'/>
<I1 Include='f1' M1='{Environment.CurrentDirectory}\b\c' M2='6'/>
<I2 Include='a2' M1='FOO.TXT' m2='c'/>
<I2 Include='b2' M1='foo/bar.txt' m2='x'/>
@ -2570,7 +2571,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
using (var env = TestEnvironment.Create())
{
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, content, null, null);
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, content);
var items = project.ItemsIgnoringCondition.Where(i => i.ItemType.Equals("I2"));
@ -2607,7 +2608,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
using (var env = TestEnvironment.Create())
{
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, content, null, null);
var project = ObjectModelHelpers.CreateInMemoryProject(env.CreateProjectCollection().Collection, content);
var items = project.ItemsIgnoringCondition.Where(i => i.ItemType.Equals("I2"));
@ -3683,8 +3684,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
project,
inputFiles: Array.Empty<string>(),
expectedInclude: new[] { "1.cs", "2.js" },
expectedMetadataPerItem: null
);
expectedMetadataPerItem: null);
}
[Theory]

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -461,8 +461,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Assert.True(metadata.IsImported);
metadata.UnevaluatedValue = "m1";
}
);
});
}
/// <summary>
/// Escaping in metadata values

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -139,8 +139,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectProperty property = project.GetProperty("MSBuildProjectDirectory");
property.UnevaluatedValue = "v";
}
);
});
}
/// <summary>
/// Set the value of a property originating in the environment.
@ -263,7 +262,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
file = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
Project import = new Project();
import.SetProperty("p", "v0");
import.Save(file);
@ -279,8 +278,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
File.Delete(file);
}
}
);
});
}
/// <summary>
/// Get the property named "p" in the project provided

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -8,7 +8,6 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Engine.UnitTests.Globbing;
using Microsoft.Build.Evaluation;
@ -16,17 +15,16 @@ using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Globbing;
using Microsoft.Build.Shared;
using Task = System.Threading.Tasks.Task;
// can't use an actual ProvenanceResult because it points to a ProjectItemElement which is hard to mock.
using ProvenanceResultTupleList = System.Collections.Generic.List<(string, Microsoft.Build.Evaluation.Operation, Microsoft.Build.Evaluation.Provenance, int)>;
using GlobResultList = System.Collections.Generic.List<(string, string[], System.Collections.Immutable.ImmutableHashSet<string>, System.Collections.Immutable.ImmutableHashSet<string>)>;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using ToolLocationHelper = Microsoft.Build.Utilities.ToolLocationHelper;
using TargetDotNetFrameworkVersion = Microsoft.Build.Utilities.TargetDotNetFrameworkVersion;
using Shouldly;
using Xunit;
using Xunit.Abstractions;
using GlobResultList = System.Collections.Generic.List<(string, string[], System.Collections.Immutable.ImmutableHashSet<string>, System.Collections.Immutable.ImmutableHashSet<string>)>;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
// can't use an actual ProvenanceResult because it points to a ProjectItemElement which is hard to mock.
using ProvenanceResultTupleList = System.Collections.Generic.List<(string, Microsoft.Build.Evaluation.Operation, Microsoft.Build.Evaluation.Provenance, int)>;
using TargetDotNetFrameworkVersion = Microsoft.Build.Utilities.TargetDotNetFrameworkVersion;
using Task = System.Threading.Tasks.Task;
using ToolLocationHelper = Microsoft.Build.Utilities.ToolLocationHelper;
#nullable disable
@ -180,7 +178,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
string content = GetSampleProjectContent();
File.WriteAllText(file, content);
@ -244,8 +242,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
XmlReader reader = XmlReader.Create(new StringReader(String.Empty));
ProjectRootElement.Create(reader);
}
);
});
}
/// <summary>
/// Reading from an XMLReader that has no content should throw the correct
@ -258,8 +255,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
XmlReader reader = XmlReader.Create(new StringReader(String.Empty));
Project project = new Project(reader);
}
);
});
}
/// <summary>
/// Reading from an XMLReader that has no content should throw the correct
@ -278,8 +274,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
Project project = (new ProjectCollection()).LoadProject(reader);
}
);
});
}
/// <summary>
@ -294,8 +289,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
XmlReader reader = XmlReader.Create(new StringReader(String.Empty));
reader.Dispose();
Project project = new Project(reader);
}
);
});
}
/// <summary>
@ -328,8 +322,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
xml.AddImport("__nonexistent__");
Project project = new Project(xml);
}
);
});
}
/// <summary>
/// Import gives invalid uri exception
@ -343,8 +336,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
xml.AddImport(@"//MSBuildExtensionsPath32)\4.0\Microsoft.VisualStudioVersion.v11.Common.props");
Project project = new Project(xml);
}
);
});
}
/// <summary>
/// Necessary but not sufficient for MSBuild evaluation to be thread safe.
@ -393,8 +385,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project(xml, null, null, new ProjectCollection(), ProjectLoadSettings.IgnoreMissingImports);
IList<ResolvedImport> imports = project.ImportsIncludingDuplicates;
imports.ShouldBeEmpty();
}
);
});
}
/// <summary>
/// Import self ignored
@ -413,7 +404,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project = new Project(collection);
project.Xml.AddImport("$(MSBuildProjectFullPath)");
file = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
project.Save(file);
project.ReevaluateIfNecessary();
@ -440,8 +431,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
MockLogger logger = new MockLogger();
collection.RegisterLogger(logger);
file = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
Project project = new Project(collection);
project.Xml.AddImport(file2);
project.Save(file);
@ -476,8 +467,8 @@ namespace Microsoft.Build.UnitTests.OM.Definition
MockLogger logger = new MockLogger();
collection.RegisterLogger(logger);
file = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
Project project = new Project(collection);
project.Xml.AddImport(file2);
project.Xml.AddImport(file2);
@ -513,9 +504,9 @@ namespace Microsoft.Build.UnitTests.OM.Definition
MockLogger logger = new MockLogger();
collection.RegisterLogger(logger);
file = FileUtilities.GetTemporaryFile();
file2 = FileUtilities.GetTemporaryFile();
file3 = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
file2 = FileUtilities.GetTemporaryFileName();
file3 = FileUtilities.GetTemporaryFileName();
Project project = new Project(collection);
project.Xml.AddImport(file2);
@ -649,7 +640,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
file = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
project.Save(file);
project.ReevaluateIfNecessary();
@ -919,8 +910,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
project.SetGlobalProperty("p", "v1");
project.ReevaluateIfNecessary();
project.SetProperty("p", "v2");
}
);
});
}
/// <summary>
/// Setting environment property should create a real property
@ -949,8 +939,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
Project project = new Project();
project.SetProperty("msbuildprojectdirectory", "v1");
}
);
});
}
/// <summary>
/// Changing global properties with some preexisting.
@ -984,7 +973,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
#else
[Fact(Skip = "https://github.com/dotnet/msbuild/issues/276")]
#endif
[Trait("Category", "mono-osx-failing")]
public void ChangeGlobalPropertiesInitiallyFromProjectCollection()
{
Dictionary<string, string> initial = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
@ -1252,7 +1240,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
/// environment
/// </summary>
[Fact]
[Trait("Category", "mono-osx-failing")]
public void GetSubToolsetVersion_FromEnvironment()
{
string originalVisualStudioVersion = Environment.GetEnvironmentVariable("VisualStudioVersion");
@ -1359,7 +1346,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
ProjectRootElement.Create().Save(path);
Project project = new Project(path);
@ -1387,7 +1374,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
try
{
path = FileUtilities.GetTemporaryFile();
path = FileUtilities.GetTemporaryFileName();
ProjectRootElement import = ProjectRootElement.Create(path);
import.Save();
@ -2080,7 +2067,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ObjectModelHelpers.CleanupFileContents(@"<Project xmlns='msbuildnamespace'>
</Project>");
string importFileName = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile() + ".proj";
string importFileName = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName() + ".proj";
File.WriteAllText(importFileName, importProjectContent);
string projectContent =
@ -2131,8 +2118,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectRootElement xml = ProjectRootElement.Create();
xml.AddUsingTask("x", "@(x->'%(x)')", null);
Project project = new Project(xml);
}
);
});
}
/// <summary>
/// UsingTask expansion should throw InvalidProjectFileException
@ -2146,8 +2132,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectRootElement xml = ProjectRootElement.Create();
xml.AddUsingTask("@(x->'%(x)')", "y", null);
Project project = new Project(xml);
}
);
});
}
/// <summary>
/// UsingTask expansion should throw InvalidProjectFileException
@ -2161,8 +2146,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
ProjectRootElement xml = ProjectRootElement.Create();
xml.AddUsingTask("x", null, "@(x->'%(x)')");
Project project = new Project(xml);
}
);
});
}
/// <summary>
/// Saving project should make it "clean" for saving
@ -2180,7 +2164,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
string file = null;
try
{
file = FileUtilities.GetTemporaryFile();
file = FileUtilities.GetTemporaryFileName();
project.Save(file);
}
finally
@ -2348,8 +2332,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
Project project = new Project();
project.RemoveItems(new List<ProjectItem>() { null });
}
);
});
}
/// <summary>
/// Remove several items where removing the first one
@ -2368,8 +2351,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
Project project2 = new Project(root2);
project1.RemoveItems(project2.Items);
}
);
});
}
/// <summary>
/// Remove an item that is no longer attached. For convenience,
@ -2406,8 +2388,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
globalProperties.Add("msbuildprojectdirectory", "x");
Project project = new Project(globalProperties, null, new ProjectCollection());
}
);
});
}
/// <summary>
/// Reserved property in project collection global properties should log an error then rethrow
@ -2431,8 +2412,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
logger.AssertLogContains("MSB4177");
}
}
);
});
}
/// <summary>
/// Invalid property (reserved name) in project collection global properties should log an error then rethrow
@ -2456,8 +2436,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
logger.AssertLogContains("MSB4177");
}
}
);
});
}
/// <summary>
/// Create tree like this
@ -2527,8 +2506,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
{
logger.AssertLogContains("MSB4177");
}
}
);
});
}
/// <summary>
/// Create a structure of various imports and verify that project.GetLogicalProject()
@ -2642,8 +2620,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
</Project>
");
Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));
}
);
});
}
[Fact]
@ -2691,8 +2668,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
</Project>
");
Project project = new Project(XmlReader.Create(new StringReader(projectOriginalContents)));
}
);
});
}
[Fact]
@ -3677,28 +3653,28 @@ namespace Microsoft.Build.UnitTests.OM.Definition
}
[Theory]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*` Exclude=`c*;d*`/>
// <A Remove=`e*;f*`/>
// ",
// new[] {"ba"},
// new[] {"a", "ca", "da", "ea", "fa"}
// )]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*` Exclude=`c*;d*`/>
// ",
// new[] {"ba", "ea", "fa"},
// new[] {"a", "ca", "da"}
// )]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*`/>
// ",
// new[] {"ba", "ca", "da", "ea", "fa"},
// new[] {"a"}
// )]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*` Exclude=`c*;d*`/>
// <A Remove=`e*;f*`/>
// ",
// new[] {"ba"},
// new[] {"a", "ca", "da", "ea", "fa"}
// )]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*` Exclude=`c*;d*`/>
// ",
// new[] {"ba", "ea", "fa"},
// new[] {"a", "ca", "da"}
// )]
// [InlineData(
// @"
// <A Include=`a;b*;c*;d*;e*;f*`/>
// ",
// new[] {"ba", "ca", "da", "ea", "fa"},
// new[] {"a"}
// )]
[InlineData(
@"
<E Include=`b`/>
@ -3708,13 +3684,11 @@ namespace Microsoft.Build.UnitTests.OM.Definition
<A Remove=`@(R)`/>
",
new[] { "aa", "bb", "cc" },
new[] { "b", "c" }
)]
new[] { "b", "c" })]
[InlineData(
@"<A Include=`ab*;b|c*;de*`/>",
new[] { "ab", "de" },
new[] { "bc", "b|c", "b", "c" }
)]
new[] { "bc", "b|c", "b", "c" })]
public void GetAllGlobsShouldProduceGlobThatMatches(string itemContents, string[] stringsThatShouldMatch, string[] stringsThatShouldNotMatch)
{
var projectTemplate =
@ -3877,8 +3851,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportedEventFalseCondition()
{
using (var env = TestEnvironment.Create(_output))
@ -3922,8 +3894,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportedEventNoMatchingFiles()
{
using (var env = TestEnvironment.Create(_output))
@ -4183,8 +4153,6 @@ namespace Microsoft.Build.UnitTests.OM.Definition
[Fact]
[Trait("Category", "netcore-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "netcore-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-osx-failing")] // https://github.com/dotnet/msbuild/issues/2226
[Trait("Category", "mono-linux-failing")] // https://github.com/dotnet/msbuild/issues/2226
public void ProjectImportEvent()
{
using (var env = TestEnvironment.Create(_output))

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -104,7 +104,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
</Project>";
importContents = Expand(importContents);
_importFilename = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile() + ".targets";
_importFilename = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName() + ".targets";
File.WriteAllText(_importFilename, importContents);
}
@ -136,8 +136,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
property.UnevaluatedValue = NewValue;
}
);
});
}
/// <summary>
/// Tests against edits into imported properties through the project.
@ -168,8 +167,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
project.RemoveProperty(property);
}
);
});
}
#endregion
@ -188,8 +186,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.ItemType = "NewItemType";
}
);
});
}
/// <summary>
/// Tests imported item renaming.
@ -204,8 +201,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.Rename("NewItemName");
}
);
});
}
/// <summary>
/// Tests imported item SetUnevaluatedValue.
@ -220,8 +216,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.UnevaluatedInclude = "NewItemName";
}
);
});
}
/// <summary>
/// Tests imported item removal.
@ -236,8 +231,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
project.RemoveItem(item);
}
);
});
}
/// <summary>
/// Tests project item type change.
@ -312,8 +306,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.SetMetadataValue(ImportedMetadataName, "NewImportedMetadataValue");
}
);
});
}
/// <summary>
/// Tests setting new metadata in import.
@ -328,8 +321,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.SetMetadataValue("NewMetadata", "NewImportedMetadataValue");
}
);
});
}
/// <summary>
/// Tests setting new metadata in import.
@ -344,8 +336,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
metadata.UnevaluatedValue = NewValue;
}
);
});
}
/// <summary>
/// Tests removing metadata in import.
@ -360,8 +351,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.RemoveMetadata(ImportedMetadataName);
}
);
});
}
/// <summary>
/// Tests setting existing metadata in import.
@ -439,8 +429,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
metadata.UnevaluatedValue = NewValue;
}
);
});
}
/// <summary>
/// Tests removing metadata in imported item definition.
@ -455,8 +444,7 @@ namespace Microsoft.Build.UnitTests.OM.Definition
// This should throw
item.RemoveMetadata(NonOverridableMetadataName);
}
);
});
}
/// <summary>
/// Tests setting existing metadata in import.

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
@ -9,12 +9,11 @@ using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using ForwardingLoggerRecord = Microsoft.Build.Logging.ForwardingLoggerRecord;
using Microsoft.Build.Shared;
using Xunit;
using Xunit.Abstractions;
using ForwardingLoggerRecord = Microsoft.Build.Logging.ForwardingLoggerRecord;
#nullable disable
@ -157,8 +156,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance p = GetEmptyProjectInstance();
p.AddItem(null, "i1");
}
);
});
}
/// <summary>
/// Add item empty item type
@ -170,8 +168,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance p = GetEmptyProjectInstance();
p.AddItem(String.Empty, "i1");
}
);
});
}
/// <summary>
/// Add item null include
@ -183,8 +180,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance p = GetEmptyProjectInstance();
p.AddItem("i", null);
}
);
});
}
/// <summary>
/// Add item null metadata
@ -349,8 +345,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance instance = new ProjectInstance(ProjectRootElement.Create());
instance.Build(new string[] { null }, null);
}
);
});
}
/// <summary>
/// Null logger in array should give ArgumentNullException
@ -362,8 +357,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance instance = new ProjectInstance(ProjectRootElement.Create());
instance.Build("t", new ILogger[] { null });
}
);
});
}
/// <summary>
/// Null remote logger in array should give ArgumentNullException
@ -375,8 +369,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectInstance instance = new ProjectInstance(ProjectRootElement.Create());
instance.Build("t", null, new ForwardingLoggerRecord[] { null });
}
);
});
}
/// <summary>
/// Null target name should imply the default target

Просмотреть файл

@ -1,22 +1,21 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using Microsoft.Build.Construction;
using Microsoft.Build.Definition;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
using Xunit;
using Shouldly;
using System.Linq;
using Xunit;
using Xunit.NetCore.Extensions;
using InvalidProjectFileException = Microsoft.Build.Exceptions.InvalidProjectFileException;
#nullable disable
@ -128,8 +127,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectItemInstance item = GetItemInstance();
item.EvaluatedInclude = String.Empty;
}
);
});
}
/// <summary>
/// Set include to invalid null value
@ -141,8 +139,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectItemInstance item = GetItemInstance();
item.EvaluatedInclude = null;
}
);
});
}
/// <summary>
/// Create an item with a metadatum that has a null value
@ -204,8 +201,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectItemInstance item = GetItemInstance();
item.SetMetadata(null, "m1");
}
);
});
}
/// <summary>
/// Set metadata with invalid empty name
@ -217,8 +213,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectItemInstance item = GetItemInstance();
item.SetMetadata(String.Empty, "m1");
}
);
});
}
/// <summary>
/// Cast to ITaskItem
@ -647,8 +642,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
";
GetOneItem(content);
}
);
});
}
/// <summary>
/// Two items should each get their own values for built-in metadata
@ -913,8 +907,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
/// Log warning for drive enumerating wildcards that exist in projects on Windows platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
TargetItemWithIncludeAndExclude,
@"z:$(Microsoft_WindowsAzure_EngSys)\**\*",
@ -955,8 +948,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
/// Log warning for drive enumerating wildcards that exist in projects on Unix platform.
/// </summary>
[ActiveIssue("https://github.com/dotnet/msbuild/issues/7330")]
[PlatformSpecific(TestPlatforms.AnyUnix)]
[Theory]
[UnixOnlyTheory]
[InlineData(
TargetWithDefinedPropertyAndItemWithInclude,
@"$(Microsoft_WindowsAzure_EngSys)**",
@ -986,8 +978,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
/// <summary>
/// Tests target item evaluation resulting in no build failures.
/// </summary>
[PlatformSpecific(TestPlatforms.Windows)]
[Theory]
[WindowsOnlyTheory]
[InlineData(
TargetWithDefinedPropertyAndItemWithInclude,
@"$(Microsoft_WindowsAzure_EngSys)*.cs",

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using Microsoft.Build.Evaluation;
@ -70,8 +70,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
{
ProjectPropertyInstance property = GetPropertyInstance();
property.EvaluatedValue = null;
}
);
});
}
/// <summary>
/// Immutable getter

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.IO;
@ -112,7 +112,7 @@ namespace Microsoft.Build.UnitTests.OM.Instance
try
{
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFile();
path = Microsoft.Build.Shared.FileUtilities.GetTemporaryFileName();
ProjectRootElement projectXml = ProjectRootElement.Create(path);
projectXml.Save();

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using System.Xml;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.IO;
using Xunit;

Просмотреть файл

@ -79,7 +79,10 @@
<Link>TestData\GlobbingTestData.cs</Link>
</Compile>
<Compile Include="..\Shared\ProcessExtensions.cs" />
<Compile Include="..\UnitTests.Shared\EnvironmentProvider.cs" />
<Compile Include="..\UnitTests.Shared\RunnerUtilities.cs" />
<Compile Include="..\UnitTests.Shared\DriveMapping.cs" />
<Compile Include="..\UnitTests.Shared\DummyMappedDrive.cs" />
<None Include="..\Shared\UnitTests\App.config">
<Link>App.config</Link>
<SubType>Designer</SubType>

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if !DEBUG
using Microsoft.Build.UnitTests;
@ -9,6 +9,7 @@ using System.IO;
using Xunit;
#endif
using Xunit.Abstractions;
using Xunit.NetCore.Extensions;
namespace Microsoft.Build.Engine.OM.UnitTests
{
@ -23,8 +24,7 @@ namespace Microsoft.Build.Engine.OM.UnitTests
// This NuGet version cannot locate other assemblies when parsing solutions at restore time. This includes localized strings required in debug mode.
// NuGet version 4.1.0 was somewhat arbitrarily chosen. 3.5 breaks with an unrelated error, and 4.8.2 does not fail when a new dependency is introduced. This is a safe middle point.
#if !DEBUG
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
[Fact]
[WindowsFullFrameworkOnlyFact]
public void TestOldNuget()
{
string msbuildExePath = Path.GetDirectoryName(RunnerUtilities.PathToCurrentlyRunningMsBuildExe)!;

Просмотреть файл

@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
@ -230,7 +231,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
this.Disk = this.ImmutableDisk.GetSubFolder("Mutable");
List<string> stdFiles = new List<string>();
for (int i=0; i< stdFilesCount; i++)
for (int i = 0; i < stdFilesCount; i++)
{
stdFiles.Add(this.ImmutableDisk.WriteProjectFile($"Proj{i}.proj", TestCollectionGroup.SampleProjectFile));
}
@ -253,7 +254,9 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
foreach (var p in linker.Collection.LoadedProjects)
{
if (!toKeep.Contains(p))
{
toUnload.Add(p);
}
}
foreach (var p in toUnload)

Просмотреть файл

@ -1,17 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Construction;
using Microsoft.Build.ObjectModelRemoting;
using Microsoft.Build.Evaluation;
using Microsoft.Build.ObjectModelRemoting;
using Xunit;
using System.Collections;
internal class ElementLinkPair<T> : LinkPair<T>
where T : ProjectElement
@ -73,7 +74,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public ElementLinkPair<CT> AddNewLabeledChaildWithVerify<CT>(ObjectType where, string label, Func<T, string, CT> adder)
where CT : ProjectElement
=> AddNewChaildWithVerify(where, label,
(t, l)=>
(t, l) =>
{
var ct = adder(t, l);
Assert.NotNull(ct);
@ -141,7 +142,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
return result;
}
public ICollection<ElementLinkPair<CT>> QueryChildrenWithValidation<CT>(Func<T,IEnumerable> getter, Func<CT, bool> matcher)
public ICollection<ElementLinkPair<CT>> QueryChildrenWithValidation<CT>(Func<T, IEnumerable> getter, Func<CT, bool> matcher)
where CT : ProjectElement
{
var viewResult = new List<CT>();
@ -204,9 +205,9 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
}
}
internal class ProjectXmlPair : ElementLinkPair<ProjectRootElement>
internal sealed class ProjectXmlPair : ElementLinkPair<ProjectRootElement>
{
ProjectPair Project { get; }
private ProjectPair Project { get; }
public ProjectXmlPair(ProjectPair pair) : base(null, pair.View.Xml, pair.Real.Xml) { this.Project = pair; this.PRE = this; }
public ProjectXmlPair(ProjectRootElement viewXml, ProjectRootElement realXml) : base(null, viewXml, realXml) { this.PRE = this; }
@ -246,7 +247,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void VerifySameLocation(ElementLocation expected, ElementLocation actual, ValidationContext context = null)
{
if (object.ReferenceEquals(expected, actual)) return;
if (object.ReferenceEquals(expected, actual))
{
return;
}
if (context?.ValidateLocation != null)
{
@ -267,10 +271,14 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
return LinkedObjectsFactory.GetLink(obj) != null;
}
private static bool dbgIgnoreLinked = false;
private static bool dbgIgnoreLinked = false;
public static void VerifyNotLinked(object obj)
{
if (dbgIgnoreLinked) return;
if (dbgIgnoreLinked)
{
return;
}
Assert.True(obj == null || !IsLinkedObject(obj));
}
@ -278,8 +286,15 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static T GetRealObject<T>(T view)
where T : class
{
if (view == null) return null;
if (!IsLinkedObject(view)) return view;
if (view == null)
{
return null;
}
if (!IsLinkedObject(view))
{
return view;
}
var link = LinkedObjectsFactory.GetLink(view) as ILinkMock;
Assert.NotNull(link);
@ -293,7 +308,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void VerifyLinked(object obj)
{
if (dbgIgnoreLinked) return;
if (dbgIgnoreLinked)
{
return;
}
Assert.True(obj == null || IsLinkedObject(obj));
}
@ -301,21 +320,33 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void VerifyNotNull(object obj, bool linked)
{
Assert.NotNull(obj);
if (dbgIgnoreLinked) return;
if (dbgIgnoreLinked)
{
return;
}
Assert.Equal(linked, IsLinkedObject(obj));
}
public static void VerifyNotLinkedNotNull(object obj)
{
Assert.NotNull(obj);
if (dbgIgnoreLinked) return;
if (dbgIgnoreLinked)
{
return;
}
Assert.True(!IsLinkedObject(obj));
}
public static void VerifyLinkedNotNull(object obj)
{
Assert.NotNull(obj);
if (dbgIgnoreLinked) return;
if (dbgIgnoreLinked)
{
return;
}
Assert.True(IsLinkedObject(obj));
}
@ -344,7 +375,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
private static void VerifyProjectElementViewInternal(ProjectElement viewXml, ProjectElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyLinkedNotNull(viewXml);
VerifyNotLinkedNotNull(realXml);
@ -353,7 +387,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
VerifySameLocation(realXml.LabelLocation, viewXml.LabelLocation, context);
VerifySameLocationWithException(()=>realXml.ConditionLocation, ()=>viewXml.ConditionLocation, context);
VerifySameLocationWithException(() => realXml.ConditionLocation, () => viewXml.ConditionLocation, context);
VerifyNotLinked(realXml.ContainingProject);
VerifyLinked(viewXml.ContainingProject);
@ -379,7 +413,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
private static void VerifyProjectElementContainerView(ProjectElementContainer viewXml, ProjectElementContainer realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElementViewInternal(viewXml, realXml, context);
Assert.Equal(realXml.Count, viewXml.Count);
@ -393,7 +431,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
var realChild = realXml.FirstChild;
var viewChild = viewXml.FirstChild;
while (realChild != null )
while (realChild != null)
{
Assert.NotNull(viewChild);
Assert.Same(realChild.Parent, realXml);
@ -458,7 +496,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void VerifyProjectElement(ProjectElement viewXml, ProjectElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
if (viewXml is ProjectElementContainer viewContainer)
{
@ -474,7 +515,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectRootElement viewXml, ProjectRootElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.FullPath, viewXml.FullPath);
@ -517,7 +562,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectChooseElement viewXml, ProjectChooseElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -527,7 +576,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectWhenElement viewXml, ProjectWhenElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -538,7 +591,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectOtherwiseElement viewXml, ProjectOtherwiseElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -549,7 +606,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectExtensionsElement viewXml, ProjectExtensionsElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.Content, viewXml.Content);
@ -557,7 +618,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectMetadataElement viewXml, ProjectMetadataElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.Name, viewXml.Name);
@ -567,7 +632,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectTaskElement viewXml, ProjectTaskElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.Name, viewXml.Name);
@ -627,7 +696,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectOutputElement viewXml, ProjectOutputElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.TaskParameter, viewXml.TaskParameter);
@ -641,7 +714,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectUsingTaskBodyElement viewXml, ProjectUsingTaskBodyElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -652,7 +728,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectUsingTaskParameterElement viewXml, ProjectUsingTaskParameterElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -667,7 +746,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(UsingTaskParameterGroupElement viewXml, UsingTaskParameterGroupElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -676,7 +758,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectUsingTaskElement viewXml, ProjectUsingTaskElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -704,7 +790,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectTargetElement viewXml, ProjectTargetElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -733,7 +823,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectImportElement viewXml, ProjectImportElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
@ -752,7 +846,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectImportGroupElement viewXml, ProjectImportGroupElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
ViewValidation.Verify(viewXml.Imports, realXml.Imports, ViewValidation.Verify, context);
@ -760,7 +858,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectItemDefinitionElement viewXml, ProjectItemDefinitionElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.ItemType, viewXml.ItemType);
@ -769,7 +871,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectItemDefinitionGroupElement viewXml, ProjectItemDefinitionGroupElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
ViewValidation.Verify(viewXml.ItemDefinitions, realXml.ItemDefinitions, ViewValidation.Verify, context);
@ -777,7 +883,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectItemElement viewXml, ProjectItemElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.ItemType, viewXml.ItemType);
@ -790,20 +900,24 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
Assert.Equal(realXml.KeepDuplicates, viewXml.KeepDuplicates);
Assert.Equal(realXml.HasMetadata, viewXml.HasMetadata);
Verify(viewXml.Metadata, realXml.Metadata, ViewValidation.Verify, context);
Verify(viewXml.Metadata, realXml.Metadata, ViewValidation.Verify, context);
VerifySameLocation(realXml.IncludeLocation, viewXml.IncludeLocation, context);
VerifySameLocation(realXml.ExcludeLocation, viewXml.ExcludeLocation, context);
VerifySameLocation(realXml.RemoveLocation, viewXml.RemoveLocation, context);
VerifySameLocation(realXml.UpdateLocation, viewXml.UpdateLocation, context);
VerifySameLocation(realXml.KeepMetadataLocation, viewXml.KeepMetadataLocation, context);
VerifySameLocation(realXml.RemoveMetadataLocation, viewXml.RemoveMetadataLocation, context);
VerifySameLocation(realXml.KeepDuplicatesLocation, viewXml.KeepDuplicatesLocation, context);
VerifySameLocation(realXml.IncludeLocation, viewXml.IncludeLocation, context);
VerifySameLocation(realXml.ExcludeLocation, viewXml.ExcludeLocation, context);
VerifySameLocation(realXml.RemoveLocation, viewXml.RemoveLocation, context);
VerifySameLocation(realXml.UpdateLocation, viewXml.UpdateLocation, context);
VerifySameLocation(realXml.KeepMetadataLocation, viewXml.KeepMetadataLocation, context);
VerifySameLocation(realXml.RemoveMetadataLocation, viewXml.RemoveMetadataLocation, context);
VerifySameLocation(realXml.KeepDuplicatesLocation, viewXml.KeepDuplicatesLocation, context);
}
public static void Verify(ProjectItemGroupElement viewXml, ProjectItemGroupElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Verify(viewXml.Items, realXml.Items, Verify, context);
@ -811,7 +925,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectPropertyElement viewXml, ProjectPropertyElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.Name, viewXml.Name);
@ -820,7 +938,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectPropertyGroupElement viewXml, ProjectPropertyGroupElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Verify(viewXml.Properties, realXml.Properties, Verify, context);
Verify(viewXml.PropertiesReversed, realXml.PropertiesReversed, Verify, context);
@ -828,7 +950,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectSdkElement viewXml, ProjectSdkElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.Name, viewXml.Name);
Assert.Equal(realXml.Version, viewXml.Version);
@ -837,7 +963,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(ProjectOnErrorElement viewXml, ProjectOnErrorElement realXml, ValidationContext context = null)
{
if (viewXml == null && realXml == null) return;
if (viewXml == null && realXml == null)
{
return;
}
VerifyProjectElement(viewXml, realXml, context);
Assert.Equal(realXml.ExecuteTargetsAttribute, viewXml.ExecuteTargetsAttribute);

Просмотреть файл

@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
@ -93,7 +94,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
}
}
internal class ValidationContext
internal sealed class ValidationContext
{
public ValidationContext() { }
public ValidationContext(ProjectPair pair) { this.Pair = pair; }
@ -121,48 +122,165 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
// "Slow" Verify, probing all known link types
public static void VerifyFindType(object view, object real, ValidationContext context = null)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
VerifyLinkedNotNull(view);
VerifyNotLinkedNotNull(real);
// construction
if (VerifyCheckType<ProjectMetadataElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectChooseElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectWhenElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectOtherwiseElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectTaskElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectOutputElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectUsingTaskBodyElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectUsingTaskParameterElement>(view, real, context, Verify)) return;
if (VerifyCheckType<UsingTaskParameterGroupElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectUsingTaskElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectTargetElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectRootElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectExtensionsElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectImportElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectImportGroupElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItemDefinitionElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItemDefinitionGroupElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItemElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItemGroupElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectPropertyElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectPropertyGroupElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectSdkElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectOnErrorElement>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectMetadataElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectChooseElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectWhenElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectOtherwiseElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectTaskElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectOutputElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectUsingTaskBodyElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectUsingTaskParameterElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<UsingTaskParameterGroupElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectUsingTaskElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectTargetElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectRootElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectExtensionsElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectImportElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectImportGroupElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItemDefinitionElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItemDefinitionGroupElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItemElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItemGroupElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectPropertyElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectPropertyGroupElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectSdkElement>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectOnErrorElement>(view, real, context, Verify))
{
return;
}
// evaluation
if (VerifyCheckType<ProjectProperty>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectMetadata>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItemDefinition>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectItem>(view, real, context, Verify)) return;
if (VerifyCheckType<Project>(view, real, context, Verify)) return;
if (VerifyCheckType<ProjectProperty>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectMetadata>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItemDefinition>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<ProjectItem>(view, real, context, Verify))
{
return;
}
if (VerifyCheckType<Project>(view, real, context, Verify))
{
return;
}
throw new NotImplementedException($"Unknown type:{view.GetType().Name}");
}
public static void VerifyMetadata(IEnumerable<KeyValuePair<string, string>> expected, Func<string, string> getMetadata, Func<string, bool> hasMetadata = null)
{
if (expected == null) return;
if (expected == null)
{
return;
}
foreach (var md in expected)
{
@ -177,7 +295,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify<T>(IEnumerable<T> viewCollection, IEnumerable<T> realCollection, Action<T, T, ValidationContext> validator, ValidationContext context = null)
{
if (viewCollection == null && realCollection == null) return;
if (viewCollection == null && realCollection == null)
{
return;
}
Assert.NotNull(viewCollection);
Assert.NotNull(realCollection);
@ -192,7 +314,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify<T>(IDictionary<string, T> viewCollection, IDictionary<string, T> realCollection, Action<T, T, ValidationContext> validator, ValidationContext context = null)
{
if (viewCollection == null && realCollection == null) return;
if (viewCollection == null && realCollection == null)
{
return;
}
Assert.NotNull(viewCollection);
Assert.NotNull(realCollection);

Просмотреть файл

@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
@ -7,10 +8,10 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Evaluation;
using Xunit;
using Microsoft.Build.Framework;
using Xunit;
internal class ProjectPair : LinkPair<Project>
internal sealed class ProjectPair : LinkPair<Project>
{
public ProjectPair(Project view, Project real)
: base(view, real)
@ -68,7 +69,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
var viewItems = this.View.GetItemsByEvaluatedInclude(evaluatedInclude);
ViewValidation.Verify(viewItems, realItems, ViewValidation.Verify, new ValidationContext(this));
if (viewItems == null || viewItems.Count == 0) return null;
if (viewItems == null || viewItems.Count == 0)
{
return null;
}
Assert.Equal(1, viewItems.Count);
return which == ObjectType.View ? viewItems.First() : realItems.First();
}
@ -93,7 +98,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
{
public static void Verify(ProjectProperty view, ProjectProperty real, ValidationContext context)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
VerifyLinkedNotNull(view);
VerifyNotLinkedNotNull(real);
@ -121,7 +130,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
// public static void Verify(ProjectMetadata view, ProjectMetadata real) => Verify(view, real, null);
public static void Verify(ProjectMetadata view, ProjectMetadata real, ValidationContext context)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
VerifyLinkedNotNull(view);
VerifyNotLinkedNotNull(real);
@ -150,7 +163,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
// public static void Verify(ProjectItemDefinition view, ProjectItemDefinition real) => Verify(view, real, null);
public static void Verify(ProjectItemDefinition view, ProjectItemDefinition real, ValidationContext context)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
VerifyLinkedNotNull(view);
VerifyNotLinkedNotNull(real);
@ -188,7 +205,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
// public static void Verify(ProjectItem view, ProjectItem real) => Verify(view, real, null);
public static void Verify(ProjectItem view, ProjectItem real, ValidationContext context = null)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
VerifyLinkedNotNull(view);
VerifyNotLinkedNotNull(real);
@ -234,7 +255,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
private static void Verify(SdkReference view, SdkReference real, ValidationContext context = null)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
Assert.NotNull(view);
Assert.NotNull(real);
@ -245,7 +270,11 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
private static void Verify(SdkResult view, SdkResult real, ValidationContext context = null)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
Assert.NotNull(view);
Assert.NotNull(real);
Assert.Equal(real.Success, view.Success);
@ -263,12 +292,16 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
private static void Verify(List<string> viewProps, List<string> realProps, ValidationContext context = null)
{
if (viewProps == null && realProps == null) return;
if (viewProps == null && realProps == null)
{
return;
}
Assert.NotNull(viewProps);
Assert.NotNull(realProps);
Assert.Equal(realProps.Count, viewProps.Count);
for (int i = 0; i< realProps.Count; i++)
for (int i = 0; i < realProps.Count; i++)
{
Assert.Equal(realProps[i], viewProps[i]);
}
@ -276,14 +309,22 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
public static void Verify(Project view, Project real, ValidationContext context = null)
{
if (view == null && real == null) return;
if (view == null && real == null)
{
return;
}
var pair = new ProjectPair(view, real);
Verify(pair, context);
}
public static void Verify(ProjectPair pair, ValidationContext context = null)
{
if (pair == null) return;
if (pair == null)
{
return;
}
var real = pair.Real;
var view = pair.View;
context ??= new ValidationContext();

Просмотреть файл

@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
@ -159,7 +160,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
newTarget1.Add2NewLabeledChildrenWithVerify<ProjectPropertyGroupElement>(NewPropertyGroup, (t, l) => t.AddPropertyGroup(), out var newPropertyGroup1, out var newPropertyGroup2);
// Add property groups
newTarget1.Append2NewChildrenWithVerify<ProjectOnErrorElement>("errTarget", (p, et) => p.CreateOnErrorElement(et), (oe, et)=>oe.ExecuteTargetsAttribute == et, out var newOnErr1, out var newOnErr2);
newTarget1.Append2NewChildrenWithVerify<ProjectOnErrorElement>("errTarget", (p, et) => p.CreateOnErrorElement(et), (oe, et) => oe.ExecuteTargetsAttribute == et, out var newOnErr1, out var newOnErr2);
// string setters
@ -193,7 +194,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
// removes
newTarget1.View.RemoveChild(newTask2.View);
Assert.ThrowsAny<ArgumentException>( () => newTarget1.Real.RemoveChild(newTask2.Real) );
Assert.ThrowsAny<ArgumentException>(() => newTarget1.Real.RemoveChild(newTask2.Real));
Assert.Equal(1, newTarget1.View.Tasks.Count);
newTarget1.Real.RemoveChild(newTask1.Real);
Assert.ThrowsAny<ArgumentException>(() => newTarget1.View.RemoveChild(newTask1.View));
@ -264,9 +265,9 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
newTask.VerifySetter(paramValue.Ver(i), (t) => t.GetParameter(paramName.Ver(i)), (t, v) => t.SetParameter(paramName.Ver(i), v));
}
newTask.Verify();
newTask.Verify();
Assert.Equal(5, newTask.View.Parameters.Count);
for (int i = 1; i<= 5; i++)
for (int i = 1; i <= 5; i++)
{
Assert.Equal(paramValue.Ver(i), newTask.View.Parameters[paramName.Ver(i)]);
}
@ -320,7 +321,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
const string NewOutputItem = "NewOutputItem";
const string ItemType = "CPPSource";
var newOutputItem = newTask.AddNewChaildWithVerify<ProjectOutputElement>(ObjectType.View, NewOutputItem, (t, n) => t.AddOutputItem(n, ItemType), (oi, n) => oi.TaskParameter == n);
var newOutputItem = newTask.AddNewChaildWithVerify<ProjectOutputElement>(ObjectType.View, NewOutputItem, (t, n) => t.AddOutputItem(n, ItemType), (oi, n) => oi.TaskParameter == n);
Assert.True(newOutputItem.View.IsOutputItem);
Assert.False(newOutputItem.View.IsOutputProperty);
@ -387,7 +388,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
Assert.Null(choose.View.OtherwiseElement);
var otherWise = choose.AppendNewChaildWithVerify<ProjectOtherwiseElement>(ObjectType.View, "when", (p, l) => p.CreateOtherwiseElement(), (p,l) => true);
var otherWise = choose.AppendNewChaildWithVerify<ProjectOtherwiseElement>(ObjectType.View, "when", (p, l) => p.CreateOtherwiseElement(), (p, l) => true);
Assert.Same(otherWise.View, choose.View.OtherwiseElement);
Assert.Same(otherWise.Real, choose.Real.OtherwiseElement);
@ -410,7 +411,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
var xmlPair = new ProjectXmlPair(pair);
var choose = xmlPair.AppendNewChaildWithVerify<ProjectChooseElement>(ObjectType.View, "choose", (p, s) => p.CreateChooseElement(), (p, s) => true);
var when = choose.AppendNewChaildWithVerify<ProjectWhenElement>(ObjectType.View, "when", (p, s) => p.CreateWhenElement("true"), (p, s) => true);
var when = choose.AppendNewChaildWithVerify<ProjectWhenElement>(ObjectType.View, "when", (p, s) => p.CreateWhenElement("true"), (p, s) => true);
when.VerifySetter("Condition", (we) => we.Condition, (we, v) => we.Condition = v);
Assert.Empty(when.View.ChooseElements);

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable disable
@ -71,7 +71,7 @@ namespace Microsoft.Build.UnitTests.OM.ObjectModelRemoting
ViewValidation.Verify(preView, preReal);
}
[Fact]
public void ProjectChooseElementReadOnly()
{

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше