Skip to content

Commit

Permalink
Merge pull request #31597 from RikkiGibson/merge-p2
Browse files Browse the repository at this point in the history
Merge master to unmanaged constructed type feature branch
  • Loading branch information
RikkiGibson authored Dec 7, 2018
2 parents 4c0a9ee + e6c7e51 commit 036adc9
Show file tree
Hide file tree
Showing 80 changed files with 2,143 additions and 487 deletions.
45 changes: 45 additions & 0 deletions Compilers.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"solution": {
"path": "Roslyn.sln",
"projects": [
"src\\Compilers\\Core\\CodeAnalysisTest\\Microsoft.CodeAnalysis.UnitTests.csproj",
"src\\Compilers\\Core\\Portable\\Microsoft.CodeAnalysis.csproj",
"src\\Compilers\\Server\\VBCSCompiler\\VBCSCompiler.csproj",
"src\\Compilers\\Server\\VBCSCompilerTests\\VBCSCompiler.UnitTests.csproj",
"src\\Compilers\\CSharp\\csc\\csc.csproj",
"src\\Compilers\\CSharp\\Portable\\Microsoft.CodeAnalysis.CSharp.csproj",
"src\\Compilers\\CSharp\\Test\\CommandLine\\Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Emit\\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\IOperation\\Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Semantic\\Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Symbol\\Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests.csproj",
"src\\Compilers\\CSharp\\Test\\Syntax\\Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests.csproj",
"src\\Compilers\\Test\\Resources\\Core\\Microsoft.CodeAnalysis.Compiler.Test.Resources.csproj",
"src\\Compilers\\Test\\Utilities\\CSharp\\Microsoft.CodeAnalysis.CSharp.Test.Utilities.csproj",
"src\\Compilers\\Test\\Utilities\\VisualBasic\\Microsoft.CodeAnalysis.VisualBasic.Test.Utilities.vbproj",
"src\\Compilers\\VisualBasic\\Portable\\Microsoft.CodeAnalysis.VisualBasic.vbproj",
"src\\Compilers\\VisualBasic\\Test\\CommandLine\\Microsoft.CodeAnalysis.VisualBasic.CommandLine.UnitTests.vbproj",
"src\\Compilers\\VisualBasic\\Test\\Emit\\Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests.vbproj",
"src\\Compilers\\VisualBasic\\Test\\IOperation\\Roslyn.Compilers.VisualBasic.IOperation.UnitTests.vbproj",
"src\\Compilers\\VisualBasic\\Test\\Semantic\\Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests.vbproj",
"src\\Compilers\\VisualBasic\\Test\\Symbol\\Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests.vbproj",
"src\\Compilers\\VisualBasic\\Test\\Syntax\\Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests.vbproj",
"src\\Test\\PdbUtilities\\Roslyn.Test.PdbUtilities.csproj",
"src\\Compilers\\Core\\AnalyzerDriver\\AnalyzerDriver.shproj",
"src\\Compilers\\CSharp\\Test\\WinRT\\Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests.csproj",
"src\\Compilers\\Core\\MSBuildTaskTests\\Microsoft.Build.Tasks.CodeAnalysis.UnitTests.csproj",
"src\\Compilers\\VisualBasic\\vbc\\vbc.csproj",
"src\\Test\\Utilities\\Portable\\Roslyn.Test.Utilities.csproj",
"src\\Compilers\\VisualBasic\\BasicAnalyzerDriver\\BasicAnalyzerDriver.shproj",
"src\\Compilers\\CSharp\\CSharpAnalyzerDriver\\CSharpAnalyzerDriver.shproj",
"src\\Compilers\\Core\\CommandLine\\CommandLine.shproj",
"src\\Compilers\\Extension\\Roslyn.Compilers.Extension.csproj",
"src\\Dependencies\\PooledObjects\\Microsoft.CodeAnalysis.PooledObjects.shproj",
"src\\Compilers\\Core\\MSBuildTask\\Microsoft.Build.Tasks.CodeAnalysis.csproj",
"src\\NuGet\\Microsoft.Net.Compilers\\Microsoft.Net.Compilers.Package.csproj",
"src\\NuGet\\Microsoft.NETCore.Compilers\\Microsoft.NETCore.Compilers.Package.csproj",
"src\\NuGet\\Microsoft.CodeAnalysis.Compilers.Package.csproj",
"src\\NuGet\\Microsoft.CodeAnalysis.Package.csproj"
]
}
}
49 changes: 30 additions & 19 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/Targets/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->
<PropertyGroup>
<VersionPrefix>2.11.0</VersionPrefix>
<PreReleaseVersionLabel>beta2</PreReleaseVersionLabel>
<PreReleaseVersionLabel>beta3</PreReleaseVersionLabel>
<SemanticVersioningV1>true</SemanticVersioningV1>

<!--
Expand Down
150 changes: 150 additions & 0 deletions build/scripts/generate-badges.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Script for generating our badges line in the README.md

[CmdletBinding(PositionalBinding=$false)]
param ()

$branchNames = @(
'master',
'master-vs-deps',
'dev16.0-preview2',
'dev16.0-preview2-vs-deps')

function Get-AzureBadge($branchName, $jobName, $configName) {
$template = "[![Build Status](https://dev.azure.com/dnceng/public/_apis/build/status/dotnet/roslyn/roslyn-CI?label=build&branchname=$branchName&jobname=$jobName&configuration=$configName)]"
$template += "(https://dev.azure.com/dnceng/public/_build/latest?definitionId=15&branchname=$branchName)"
return $template
}

function Get-AzureLine($branchName, $jobNames) {
$line = "**$branchName**|"
foreach ($jobName in $jobNames) {
$i = $jobName.IndexOf('#')
$configName = $jobName.SubString($i + 1)
$jobName = $jobName.Substring(0, $i)

$line += Get-AzureBadge $branchName $jobName $configName
$line += "|"
}

return $line + [Environment]::NewLine
}

function Get-JenkinsBadge($branchName, $jobName) {
$template = "[![Build Status](https://ci.dot.net/buildStatus/icon?job=dotnet_roslyn/$branchName/$jobName)]"
$template += "(https://ci.dot.net/job/dotnet_roslyn/job/$branchName/job/$jobName/)"
return $template
}

function Get-JenkinsLine($branchName, $jobNames) {
$line = "**$branchName**|"
foreach ($jobName in $jobNames) {
$line += Get-JenkinsBadge $branchName $jobName
$line += "|"
}

return $line + [Environment]::NewLine
}

function Get-DesktopTable() {
$jobNames = @(
'Windows_Desktop_Unit_Tests#debug_32'
'Windows_Desktop_Unit_Tests#debug_64'
'Windows_Desktop_Unit_Tests#release_32'
'Windows_Desktop_Unit_Tests#release_64'
'Windows_Desktop_Spanish_Unit_Tests#',
'Windows_Determinism_Test#',
'Windows_Correctness_Test#'
)

$table = @'
### Desktop Unit Tests
|Branch|Debug x86|Debug x64|Release x86|Release x64|Spanish|
|:--:|:--:|:--:|:--:|:--:|:--:|
'@
foreach ($branchName in $branchNames) {
$table += Get-AzureLine $branchName $jobNames
}
return $table
}

function Get-CoreClrTable() {
$jobNames = @(
'Windows_CoreClr_Unit_Tests#debug',
'Windows_CoreClr_Unit_Tests#release',
'Linux_Test#coreclr'
)

$table = @'
### CoreClr Unit Tests
|Branch|Windows Debug|Windows Release|Linux|
|:--:|:--:|:--:|:--:|
'@

foreach ($branchName in $branchNames) {
$table += Get-AzureLine $branchName $jobNames
}
return $table
}

function Get-IntegrationTable() {
$jobNames = @(
'windows_debug_vs-integration',
'windows_release_vs-integration'
)

$table = @'
### Integration Tests
|Branch|Debug|Release|
|:--:|:--:|:--:|
'@

foreach ($branchName in $branchNames) {
$table += Get-JenkinsLine $branchName $jobNames
}
return $table

}

function Get-MiscTable() {
$jobNames = @(
'Windows_Determinism_Test#',
'Windows_Correctness_Test#',
'Linux_Test#mono'
)

$table = @'
### Misc Tests
|Branch|Determinism|Build Correctness|Mono|
|:--:|:--:|:--:|:--:|
'@

foreach ($branchName in $branchNames) {
$table += Get-AzureLine $branchName $jobNames
}
return $table
}


Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"
try {
. (Join-Path $PSScriptRoot "build-utils.ps1")


Get-DesktopTable | Write-Output
Get-CoreClrTable | Write-Output
Get-IntegrationTable | Write-Output
Get-MiscTable | Write-Output

exit 0
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}
3 changes: 2 additions & 1 deletion build/scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ do
if [[ "${runtime}" == "dotnet" ]]; then
# Disable the VB Semantic tests while we investigate the core dump issue
# https://github.com/dotnet/roslyn/issues/29660
if [[ "${file_name[@]}" == *'Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests.dll' ]]
if [[ "${file_name[@]}" == *'Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests.dll' ||
"${file_name[@]}" == *'Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests.dll' ]]
then
echo "Skipping ${file_name[@]}"
continue
Expand Down
58 changes: 54 additions & 4 deletions docs/features/nullable-reference-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,61 @@ var z = (IEnumerable<object?>)x; // no warning
```

### Method type inference
_Describe details_

_Open issue: C# spec should include rule for lower, upper, and exact bounds:
If V is a nullable reference type V1? and U is a nullable reference type U1?
then an exact inference is made from U1 to V1._
We modify the spec rule for [Fixing](https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#fixing "Fixing") to take account of types that may be equivalent (i.e. have an identity conversion) yet may not be identical in the set of bounds. The existing spec says (third bullet)

> If among the remaining candidate types `Uj` there is a unique type `V` from which there is an implicit conversion to all the other candidate types, then `Xi` is fixed to `V`.
This is not correct for C# 5 (i.e., it is a bug in the language specification), as it fails to handle bounds such as `Dictionary<object, dynamic>` and `Dictionary<dynamic, object>`, which are merged to `Dictionary<dynamic, dynamic>`. This is [an open issue](https://github.com/ECMA-TC49-TG2/spec/issues/951) that we anticipate will be addressed in the next iteration of the ECMA specification. Handling nullability properly will require additional changes beyond those in that next iteration of the ECMA spec.

When adding to the set of exact bounds of a type parameter, types that are equivalent (i.e. have an identity conversion) but not identical are merged using *invariant* rules. When adding to the set of lower bounds of a type parameter, types that are equivalent but not identical are merged using *covariant* rules. When adding to the set of upper bounds of a type parameter, types that are equivalent but not identical are merged using *contravariant* rules. In the final fixing step, types that are equivalent but not identical are merged using *covariant* rules.

Merging equivalent but not identical types is done as follows:

#### Invariant merging rules

- Merging `dynamic` and `object` results in the type `dynamic`.
- Merging tuple types that differ in element names is specified elsewhere.
- Merging equivalent types that differ in nullability is performed as follows: merging the types `Tn` and `Um` (where `n` and `m` are differing nullability annotations) results in the type `Vk` where `V` is the result of merging `T` and `U` using the invariant rule, and `k` is as follows:
- if either `n` or `m` are non-nullable, non-nullable. In this case, if the other is nullable, a warning should be produced.
- if either `n` or `m` are nullable, nullable.
- otherwise oblivious.
- Merging constructed generic types is performed as follows: Merging the types `K<A1, A2, ...>` and `K<B1, B2, ...>` results in the type `K<C1, C2, ...>` where `Ci` is the result of merging `Ai` and `Bi` by the invariant rule.
- Merging the array types `T[]` and `U[]` results in the type `V[]` where `V` is the result of merging `T` and `U` by the invariant rule.

#### Covariant merging rules

- Merging `dynamic` and `object` results in the type `dynamic`.
- Merging tuple types that differ in element names is specified elsewhere.
- Merging equivalent types that differ in nullability is performed as follows: merging the types `Tn` and `Um` (where `n` and `m` are differing nullability annotations) results in the type `Vk` where `V` is the result of merging `T` and `U` using the covariant rule, and `k` is as follows:
- if either `n` or `m` are nullable, nullable.
- if either `n` or `m` are oblivious, oblivious.
- otherwise non-nullable.
- Merging constructed generic types is performed as follows: Merging the types `K<A1, A2, ...>` and `K<B1, B2, ...>` results in the type `K<C1, C2, ...>` where `Ci` is the result of merging `Ai` and `Bi` by
- the invariant rule if `K`'s type parameter in the `i` position is invariant.
- the covariant rule if `K`'s type parameter in the `i` position is declared `out`.
- the contravariant rule if the `K`'s type parameter in the `i` position is declared `in`.
- Merging the array types `T[]` and `U[]` results in the type `V[]` where `V` is the result of merging `T` and `U` by the invariant rule.

#### Contravariant merging rules

- Merging `dynamic` and `object` results in the type `dynamic`.
- Merging tuple types that differ in element names is specified elsewhere.
- Merging equivalent types that differ in nullability is performed as follows: merging the types `Tn` and `Um` (where `n` and `m` are differing nullability annotations) results in the type `Vk` where `V` is the result of merging `T` and `U` using the contravariant rule, and `k` is as follows:
- if either `n` or `m` are non-nullable, non-nullable.
- if either `n` or `m` are oblivious, oblivious.
- otherwise nullable.
- Merging constructed generic types is performed as follows: Merging the types `K<A1, A2, ...>` and `K<B1, B2, ...>` results in the type `K<C1, C2, ...>` where `Ci` is the result of merging `Ai` and `Bi` by
- the invariant rule if `K`'s type parameter in the `i` position is invariant.
- the covariant rule if `K`'s type parameter in the `i` position is declared `in`.
- the contravariant rule if `K`'s type parameter in the `i` position is declared `out`.
- Merging the array types `T[]` and `U[]` results in the type `V[]` where `V` is the result of merging `T` and `U` by the invariant rule.

It is intended that these merging rules are associative and commutative, so that a compiler may merge a set of equivalent types pairwise in any order to compute the final result.

> ***Open issue***: these rules do not describe the handling of merging a nested generic type `K<A>.L<B>` with `K<C>.L<D>`. That should be handled the same as a hypothetical type `KL<A, B>` would be merged with `KL<C, D>`.
> ***Open issue***: these rules do not describe the handling of merging pointer types.
### Array creation
The calculation of the _best type_ element nullability uses the Conversions rules above.
Expand Down
18 changes: 18 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4640,6 +4640,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-errorendlocation Output line and column of the end location of
each error
-preferreduilang Specify the preferred output language name.
-nosdkpath Disable searching the default SDK path for standard library assemblies.
-nostdlib[+|-] Do not reference standard library (mscorlib.dll)
-subsystemversion:&lt;string&gt; Specify subsystem version of this assembly
-lib:&lt;file list&gt; Specify additional directories to search in for
Expand Down Expand Up @@ -5634,4 +5635,10 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_NullableDirectiveQualifierExpected" xml:space="preserve">
<value>Expected enable or disable</value>
</data>
</root>
<data name="ERR_ExpressionTreeCantContainRefStruct" xml:space="preserve">
<value>Expression tree cannot contain value of ref struct or restricted type '{0}'.</value>
</data>
<data name="ERR_ElseCannotStartStatement" xml:space="preserve">
<value>'else' cannot start a statement.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar

continue;

case "nosdkpath":
sdkDirectory = null;

continue;

case "out":
if (string.IsNullOrWhiteSpace(value))
{
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,8 @@ internal enum ErrorCode
ERR_NullableDirectiveQualifierExpected = 8637,
WRN_CantInferNullabilityOfMethodTypeArgs = 8638,
WRN_NoBestNullabilityArrayElements = 8639,
ERR_ExpressionTreeCantContainRefStruct = 8640,
ERR_ElseCannotStartStatement = 8641

#endregion diagnostics introduced for C# 8.0

Expand Down
Loading

0 comments on commit 036adc9

Please sign in to comment.