Skip to content

Commit fe19eb1

Browse files
Merge branch 'dotnet:main' into mhristova/enable-binskim-scan
2 parents 4326c71 + 0cad196 commit fe19eb1

File tree

81 files changed

+2895
-1814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2895
-1814
lines changed

.vsts-dotnet.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ variables:
3636
value: .NETCore
3737
- name: _DotNetValidationArtifactsCategory
3838
value: .NETCoreValidation
39+
- name: EnableReleaseOneLocBuild
40+
value: true
3941
- name: Codeql.Enabled
4042
value: true
4143

@@ -44,13 +46,30 @@ stages:
4446
displayName: Build
4547

4648
jobs:
47-
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}: # should track next-release's active dev branch
48-
- template: /eng/common/templates/job/onelocbuild.yml
49-
parameters:
50-
LclSource: lclFilesfromPackage
51-
LclPackageId: 'LCL-JUNO-PROD-MSBUILD'
52-
MirrorRepo: 'msbuild'
53-
MirrorBranch: 'main' # should match condition above
49+
- ${{ if and( ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
50+
# The localization setup for release/ branches. Note difference in LclPackageId. main branch is handled separately below.
51+
# Used for vs17.2, vs17.4, vs17.6 etc. branches only.
52+
# When the branch is setup for localization (the localization ticket needs to be created - https://aka.ms/ceChangeLocConfig, requesting change from one release branch to another),
53+
# set 'EnableReleaseOneLocBuild' to true.
54+
- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/vs') }}:
55+
- template: /eng/common/templates/job/onelocbuild.yml
56+
parameters:
57+
MirrorRepo: 'msbuild'
58+
LclSource: lclFilesfromPackage
59+
LclPackageId: 'LCL-JUNO-PROD-MSBUILDREL'
60+
MirrorBranch: ${{ replace(variables['Build.SourceBranch'], 'refs/heads/', '') }}
61+
JobNameSuffix: '_release'
62+
condition: ${{ variables.EnableReleaseOneLocBuild }}
63+
# The localization setup for main branch. Note difference in package ID. Should not be used with release/ branches.
64+
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
65+
- template: /eng/common/templates/job/onelocbuild.yml
66+
parameters:
67+
MirrorRepo: 'msbuild'
68+
LclSource: lclFilesfromPackage
69+
LclPackageId: 'LCL-JUNO-PROD-MSBUILD'
70+
MirrorBranch: 'main'
71+
JobNameSuffix: '_main'
72+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
5473

5574
- job: Windows_NT
5675
pool:

NuGet.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
77
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
88
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
9+
<add key="msbuild17.7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-DotNet-msbuild-Trusted-5785ed5c/nuget/v3/index.json" />
910
</packageSources>
1011
<disabledPackageSources />
1112
</configuration>

eng/SourceBuild.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<PropertyGroup>
66
<GitHubRepositoryName>msbuild</GitHubRepositoryName>
77
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>
8-
<SourceBuildTrimNetFrameworkTargets>true</SourceBuildTrimNetFrameworkTargets>
98
</PropertyGroup>
109

1110
<Target Name="ConfigureInnerBuildArgs" BeforeTargets="GetSourceBuildCommandConfiguration">

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
<Sha>bc3233146e1fcd393ed471d5005333c83363e0fe</Sha>
3434
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
3535
</Dependency>
36-
<Dependency Name="NuGet.Build.Tasks" Version="6.7.0-preview.2.51">
36+
<Dependency Name="NuGet.Build.Tasks" Version="6.7.0-rc.106">
3737
<Uri>https://github.com/nuget/nuget.client</Uri>
38-
<Sha>f3bb337e310ce44abda4ad73cdb0755ed940809d</Sha>
38+
<Sha>4b6a87bfe90d247f961eba41d63dbf418a56fdcc</Sha>
3939
</Dependency>
40-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.7.0-3.23318.1">
40+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.7.0-3.23324.1">
4141
<Uri>https://github.com/dotnet/roslyn</Uri>
42-
<Sha>15da8d75200f3748547d3afef2987f1c2865ca9b</Sha>
42+
<Sha>d0f4099ffa7f8ff31fd397a4a96f404e1cd7dfc7</Sha>
4343
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
4444
</Dependency>
4545
<Dependency Name="Microsoft.DotNet.XUnitExtensions" Version="6.0.0-beta.23313.5">

eng/Versions.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<!-- 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. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.7.0</VersionPrefix>
6-
<PackageValidationBaselineVersion>17.6.3</PackageValidationBaselineVersion>
5+
<VersionPrefix>17.8.0</VersionPrefix>
6+
<PackageValidationBaselineVersion>17.7.0</PackageValidationBaselineVersion>
77
<AssemblyVersion>15.1.0.0</AssemblyVersion>
88
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
99
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
@@ -51,8 +51,8 @@
5151
<MicrosoftDotNetXUnitExtensionsVersion>6.0.0-beta.23313.5</MicrosoftDotNetXUnitExtensionsVersion>
5252
<MicrosoftExtensionsDependencyModelVersion>7.0.0</MicrosoftExtensionsDependencyModelVersion>
5353
<MicrosoftIORedistVersion>6.0.0</MicrosoftIORedistVersion>
54-
<MicrosoftNetCompilersToolsetVersion>4.7.0-3.23318.1</MicrosoftNetCompilersToolsetVersion>
55-
<NuGetBuildTasksVersion>6.7.0-preview.2.51</NuGetBuildTasksVersion>
54+
<MicrosoftNetCompilersToolsetVersion>4.7.0-3.23324.1</MicrosoftNetCompilersToolsetVersion>
55+
<NuGetBuildTasksVersion>6.7.0-rc.106</NuGetBuildTasksVersion>
5656
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
5757
<SystemTextJsonVersion>7.0.0</SystemTextJsonVersion>
5858
<SystemThreadingTasksDataflowVersion>7.0.0</SystemThreadingTasksDataflowVersion>

eng/dependabot/Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
<ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true' AND $(ProjectIsDeprecated) != 'true'">
5757
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
58-
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all"/>
58+
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="all"/>
5959
<GlobalPackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.36" PrivateAssets="All" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
6060
</ItemGroup>
6161

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Globalization;
5+
using System.Runtime.InteropServices;
6+
using System.Threading;
7+
8+
using Microsoft.Build.Evaluation;
9+
10+
using Shouldly;
11+
12+
using Xunit;
13+
using Xunit.Abstractions;
14+
15+
namespace Microsoft.Build.Engine.UnitTests.Evaluation
16+
{
17+
public class ExpanderFunction_Tests
18+
{
19+
private readonly ITestOutputHelper _output;
20+
21+
public ExpanderFunction_Tests(ITestOutputHelper output) => _output = output;
22+
23+
/* Tests for TryConvertToInt */
24+
25+
[Fact]
26+
public void TryConvertToIntGivenNull()
27+
{
28+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(null, out int actual).ShouldBeFalse();
29+
actual.ShouldBe(0);
30+
}
31+
32+
[Fact]
33+
public void TryConvertToIntGivenDouble()
34+
{
35+
const double value = 10.0;
36+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
37+
actual.ShouldBe(10);
38+
}
39+
40+
[Fact]
41+
public void TryConvertToIntGivenLong()
42+
{
43+
const long value = 10;
44+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
45+
actual.ShouldBe(10);
46+
}
47+
48+
[Fact]
49+
public void TryConvertToIntGivenInt()
50+
{
51+
const int value = 10;
52+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
53+
actual.ShouldBe(10);
54+
}
55+
56+
[Fact]
57+
public void TryConvertToIntGivenString()
58+
{
59+
const string value = "10";
60+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
61+
actual.ShouldBe(10);
62+
}
63+
64+
[Fact]
65+
public void TryConvertToIntGivenDoubleWithIntMinValue()
66+
{
67+
const int expected = int.MinValue;
68+
const double value = expected;
69+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
70+
actual.ShouldBe(expected);
71+
}
72+
73+
[Fact]
74+
public void TryConvertToIntGivenDoubleWithIntMaxValue()
75+
{
76+
const int expected = int.MaxValue;
77+
const double value = expected;
78+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeTrue();
79+
actual.ShouldBe(expected);
80+
}
81+
82+
[Fact]
83+
public void TryConvertToIntGivenDoubleWithLessThanIntMinValue()
84+
{
85+
const double value = int.MinValue - 1.0;
86+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeFalse();
87+
actual.ShouldBe(0);
88+
}
89+
90+
[Fact]
91+
public void TryConvertToIntGivenDoubleWithGreaterThanIntMaxValue()
92+
{
93+
const double value = int.MaxValue + 1.0;
94+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeFalse();
95+
actual.ShouldBe(0);
96+
}
97+
98+
[Fact]
99+
public void TryConvertToIntGivenLongWithGreaterThanIntMaxValue()
100+
{
101+
const long value = int.MaxValue + 1L;
102+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToInt(value, out int actual).ShouldBeFalse();
103+
actual.ShouldBe(0);
104+
}
105+
106+
/* Tests for TryConvertToLong */
107+
108+
[Fact]
109+
public void TryConvertToLongGivenNull()
110+
{
111+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(null, out long actual).ShouldBeFalse();
112+
actual.ShouldBe(0);
113+
}
114+
115+
[Fact]
116+
public void TryConvertToLongGivenDouble()
117+
{
118+
const double value = 10.0;
119+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
120+
actual.ShouldBe(10);
121+
}
122+
123+
[Fact]
124+
public void TryConvertToLongGivenLong()
125+
{
126+
const long value = 10;
127+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
128+
actual.ShouldBe(10);
129+
}
130+
131+
[Fact]
132+
public void TryConvertToLongGivenInt()
133+
{
134+
const int value = 10;
135+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
136+
actual.ShouldBe(10);
137+
}
138+
139+
[Fact]
140+
public void TryConvertToLongGivenString()
141+
{
142+
const string value = "10";
143+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
144+
actual.ShouldBe(10);
145+
}
146+
147+
[Fact]
148+
public void TryConvertToLongGivenDoubleWithLongMinValue()
149+
{
150+
const long expected = long.MinValue;
151+
const double value = expected;
152+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
153+
actual.ShouldBe(expected);
154+
}
155+
156+
[Fact]
157+
public void TryConvertToLongGivenDoubleWithLongMaxValueShouldNotThrow()
158+
{
159+
// An OverflowException should not be thrown from TryConvertToLong().
160+
// Convert.ToInt64(double) has a defect and will throw an OverflowException
161+
// for values >= (long.MaxValue - 511) and <= long.MaxValue.
162+
_ = Should.NotThrow(() => Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong((double)long.MaxValue, out _));
163+
}
164+
165+
[Fact]
166+
public void TryConvertToLongGivenDoubleWithLongMaxValue()
167+
{
168+
const long longMaxValue = long.MaxValue;
169+
bool result = Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong((double)longMaxValue, out long actual);
170+
if (RuntimeInformation.OSArchitecture != Architecture.Arm64)
171+
{
172+
// Because of loss of precision, long.MaxValue will not 'round trip' from long to double to long.
173+
result.ShouldBeFalse();
174+
actual.ShouldBe(0);
175+
}
176+
else
177+
{
178+
// Testing on macOS 12 on Apple Silicon M1 Pro produces different result.
179+
result.ShouldBeTrue();
180+
actual.ShouldBe(longMaxValue);
181+
}
182+
}
183+
184+
[Fact]
185+
public void TryConvertToLongGivenDoubleWithVeryLargeLongValue()
186+
{
187+
// Because of loss of precision, veryLargeLong will not 'round trip' but within TryConvertToLong
188+
// the double to long conversion will pass the tolerance test. Return will be true and veryLargeLong != expected.
189+
const long veryLargeLong = long.MaxValue - 512;
190+
const double value = veryLargeLong;
191+
const long expected = 9223372036854774784L;
192+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeTrue();
193+
actual.ShouldBe(expected);
194+
}
195+
196+
[Fact]
197+
public void TryConvertToLongGivenDoubleWithLessThanLongMinValue()
198+
{
199+
const double value = -92233720368547758081D;
200+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeFalse();
201+
actual.ShouldBe(0);
202+
}
203+
204+
[Fact]
205+
public void TryConvertToLongGivenDoubleWithGreaterThanLongMaxValue()
206+
{
207+
const double value = (double)long.MaxValue + long.MaxValue;
208+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToLong(value, out long actual).ShouldBeFalse();
209+
actual.ShouldBe(0);
210+
}
211+
212+
/* Tests for TryConvertToDouble */
213+
214+
[Fact]
215+
public void TryConvertToDoubleGivenNull()
216+
{
217+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(null, out double actual).ShouldBeFalse();
218+
actual.ShouldBe(0);
219+
}
220+
221+
[Fact]
222+
public void TryConvertToDoubleGivenDouble()
223+
{
224+
const double value = 10.0;
225+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(value, out double actual).ShouldBeTrue();
226+
actual.ShouldBe(10.0);
227+
}
228+
229+
[Fact]
230+
public void TryConvertToDoubleGivenLong()
231+
{
232+
const long value = 10;
233+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(value, out double actual).ShouldBeTrue();
234+
actual.ShouldBe(10.0);
235+
}
236+
237+
[Fact]
238+
public void TryConvertToDoubleGivenInt()
239+
{
240+
const int value = 10;
241+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(value, out double actual).ShouldBeTrue();
242+
actual.ShouldBe(10.0);
243+
}
244+
245+
[Fact]
246+
public void TryConvertToDoubleGivenString()
247+
{
248+
const string value = "10";
249+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(value, out double actual).ShouldBeTrue();
250+
actual.ShouldBe(10.0);
251+
}
252+
253+
[Fact]
254+
public void TryConvertToDoubleGivenStringAndLocale()
255+
{
256+
const string value = "1,2";
257+
258+
Thread currentThread = Thread.CurrentThread;
259+
CultureInfo originalCulture = currentThread.CurrentCulture;
260+
261+
try
262+
{
263+
// English South Africa locale uses ',' as decimal separator.
264+
// The invariant culture should be used and "1,2" should be 12.0 not 1.2.
265+
var cultureEnglishSouthAfrica = CultureInfo.CreateSpecificCulture("en-ZA");
266+
currentThread.CurrentCulture = cultureEnglishSouthAfrica;
267+
Expander<IProperty, IItem>.Function<IProperty>.TryConvertToDouble(value, out double actual).ShouldBeTrue();
268+
actual.ShouldBe(12.0);
269+
}
270+
finally
271+
{
272+
// Restore CultureInfo.
273+
currentThread.CurrentCulture = originalCulture;
274+
CultureInfo.CurrentCulture = originalCulture;
275+
CultureInfo.DefaultThreadCurrentCulture = originalCulture;
276+
}
277+
}
278+
}
279+
}

0 commit comments

Comments
 (0)