Skip to content

Commit

Permalink
Merge pull request dotnet#34549 from AlekseyTs/master
Browse files Browse the repository at this point in the history
Merge Default Interface Methods feature into master
  • Loading branch information
AlekseyTs authored Mar 28, 2019
2 parents 7cb5a0c + 71e414c commit c420bea
Show file tree
Hide file tree
Showing 216 changed files with 65,144 additions and 2,085 deletions.
2 changes: 1 addition & 1 deletion Compilers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CSharpAnalyzerDriver", "src
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "BasicAnalyzerDriver", "src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.shproj", "{E8F0BAA5-7327-43D1-9A51-644E81AE55F1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IlAsmDeploy", "src\Tools\ILAsm\IlAsmDeploy.csproj", "{46B3E63A-C462-4133-9F27-3B85DA5E7D37}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILAsm", "src\Tools\ILTools\ILTools.proj", "{46B3E63A-C462-4133-9F27-3B85DA5E7D37}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packages", "Packages", "{274B96B7-F815-47E3-9CA4-4024A57A478F}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion Roslyn.sln
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Edit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnalyzerRunner", "src\Tools\AnalyzerRunner\AnalyzerRunner.csproj", "{60166C60-813C-46C4-911D-2411B4ABBC0F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IlAsmDeploy", "src\Tools\ILAsm\IlAsmDeploy.csproj", "{DA8522ED-02BC-499C-AC71-1DF884F63987}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILTools", "src\Tools\ILTools\ILTools.proj", "{DA8522ED-02BC-499C-AC71-1DF884F63987}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Debugging.Package", "src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.Package.csproj", "{FC2AE90B-2E4B-4045-9FDD-73D4F5ED6C89}"
EndProject
Expand Down
16 changes: 4 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ pr:

jobs:
- job: Windows_Desktop_Unit_Tests
pool:
name: NetCorePublic-Int-Pool
queue: BuildPool.Windows.10.Amd64.VS2017.Open
pool: dotnet-external-temp-vs2019
strategy:
maxParallel: 4
matrix:
Expand Down Expand Up @@ -92,9 +90,7 @@ jobs:
condition: not(succeeded())

- job: Windows_CoreClr_Unit_Tests
pool:
name: NetCorePublic-Int-Pool
queue: BuildPool.Windows.10.Amd64.VS2017.Open
pool: dotnet-external-temp-vs2019
strategy:
maxParallel: 2
matrix:
Expand Down Expand Up @@ -127,9 +123,7 @@ jobs:
condition: not(succeeded())

- job: Windows_Determinism_Test
pool:
name: NetCorePublic-Int-Pool
queue: BuildPool.Windows.10.Amd64.VS2017.Open
pool: dotnet-external-temp-vs2019
timeoutInMinutes: 90
steps:
- script: eng/test-determinism.cmd -configuration Debug
Expand All @@ -145,9 +139,7 @@ jobs:
condition: not(succeeded())

- job: Windows_Correctness_Test
pool:
name: NetCorePublic-Int-Pool
queue: BuildPool.Windows.10.Amd64.VS2017.Open
pool: dotnet-external-temp-vs2019
timeoutInMinutes: 90
steps:
- script: eng/test-build-correctness.cmd -configuration Release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The minimal required version of .NET Framework is 4.7.2.
- Ensure C#, VB, MSBuild, .NET Core and Visual Studio Extensibility are included in the selected work loads
- Ensure Visual Studio is on Version "RC1" or greater
- Ensure "Use Previews" is checked in Tools -> Options -> Projects and Solutions -> .NET Core
1. [.NET Core SDK 3.0 Preview 3](https://dotnet.microsoft.com/download/dotnet-core/3.0) [Windows x64 installer](https://dotnet.microsoft.com/download/thank-you/dotnet-sdk-3.0.100-preview3-windows-x64-installer)
1. [.NET Core SDK 3.0 Preview 4](https://dotnet.microsoft.com/download/dotnet-core/3.0) [Windows x64 installer](https://dotnetcli.azureedge.net/dotnet/Sdk/3.0.100-preview4-010963/dotnet-sdk-3.0.100-preview4-010963-win-x64.exe )
1. [PowerShell 5.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on Windows 7. The download link is under the "upgrading existing Windows PowerShell" heading.
1. Run Restore.cmd
1. Open Roslyn.sln
Expand Down
121 changes: 121 additions & 0 deletions docs/features/DefaultInterfaceImplementation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
Default Interface Implementation
=========================

The *Default Interface Implementation* feature enables a default implementation of an interface member to be provided as part of the interface declaration.

Here is a link to the proposal https://github.com/dotnet/csharplang/blob/master/proposals/default-interface-methods.md.

**What is supported:**
- Supplying an implementation along with declaration of a regular interface method and recognizing that implementation as default implementation for the method when a type implements the interface.
Here is an example:
```
public interface I1
{
void M1()
{
System.Console.WriteLine("Default implementation of M1 is called!!!");
}
}
class Test1 : I1
{
static void Main()
{
I1 x = new Test1();
x.M1();
}
}
```

- Supplying an implementation along with declaration of a property or an indexer and recognizing that implementation as default implementation for them when a type implements the interface.

- Supplying an implementation along with declaration of an event and recognizing that implementation as default implementation for the event when a type implements the interface.

- Using **partial**, **public**, **internal**, **private**, **protected**, **static**, **virtual**, **sealed**, **abstract**, **extern** and **async** modifiers with interface methods.

- Using **public**, **internal**, **private**, **protected**, **static**, **virtual**, **sealed**, **abstract** and **extern** modifiers with interface properties.

- Using **public**, **internal**, **private**, **protected**, **virtual**, **sealed**, **abstract** and **extern** modifiers with interface indexers.

- Using **internal**, **private**, **protected** modifiers with interface property/indexer accessors.

- Using **public**, **internal**, **private**, **protected**, **static**, **virtual**, **sealed**, **abstract** and **extern** modifiers with interface events.

- Declaring types within interfaces.

- Implementing interface methods in derived interfaces by using explicit implementation syntax, accessibility is **protected**, allowed modifiers: **extern** and **async**.

- Implementing interface properties and indexers in derived interfaces by using explicit implementation syntax, accessibility **protected**, allowed modifiers: **extern**.

- Implementing interface events in derived interfaces by using explicit implementation syntax, accessibility **protected**, no allowed modifiers.

- Declaring static fields, auto-properties and field-like events.

- Declaring operators ```+ - ! ~ ++ -- true false * / % & | ^ << >> > < >= <=``` in interfaces.

- Base access
The following forms of base-access are added (https://github.com/dotnet/csharplang/blob/master/meetings/2018/LDM-2018-11-14.md)
```
base ( <type-syntax> ) . identifier
base ( <type-syntax> ) [ argument-list ]
```

The type-syntax can refer to one of the base classes of the containing type, or one of the interfaces implemented or inherited by the containing type.

When the type-syntax refers to a class, the member lookup rules, overload resolution rules and IL emit match the rules for the 7.3 supported
forms of base-access. The difference is that the specified base class is used instead of the immediate base class. The most derived implementation
found must be a member of that class.

When the type-syntax refers to an interface:
1. The member lookup is performed in that interface, using the regular member lookup rules within interfaces, with an exception that members of
System.Object do not participate in the lookup.
2. Regular overload resolution is performed for members returned by the lookup process, virtual or abstract members are not replaced with most
derived implementations at this step (unlike the case when the type-syntax refers to a class). If result of overload resolution is a virtual
or abstract method, it must have an implementation within the specified interface type, an error is reported otherwise. That
implementation must be accessible at the call site. If result of overload resolution is a non-virtual method, the method must be declared in the
specified interface type.
3. During IL emit a **call** (non-virtual call) instruction is used to invoke methods. If result of overload resolution on the previous step is
a virtual or abstract method, the implementation of the method from the specified interface is used as the target for the instruction.

Given the accessibility requirements for the most specific interface implementation, accessibility of implementations provided in derived interfaces
is changed to **protected**.

**Open issues and work items** are tracked in https://github.com/dotnet/roslyn/issues/17952.

**Parts of ECMA-335 that become obsolete/inaccurate/incomplete**
>I.8.5.3.2 Accessibility of members and nested types
Members (other than nested types) defined by an interface shall be public.
I.8.9.4 Interface type definition
Similarly, an interface type definition shall not provide implementations for any methods on the
values of its type.
Interfaces can have static or virtual methods, but shall not have instance methods.
However, since accessibility attributes are relative to the implementing type rather
than the interface itself, all members of an interface shall have public accessibility, ...
I.8.11.1 Method definitions
All non-static methods of an interface definition are abstract.
All non-static method definitions in interface definitions shall be virtual methods.
II.10.4 Method implementat ion requirements
II.12 Semantics of interfaces
Interfaces can have static fields and methods, but they shall not have instance fields or
methods. Interfaces can define virtual methods, but only if those methods are abstract
(see Partition I and §II.15.4.2.4).
II.12.2 Implement ing virtual methods on interfaces
If the class defines any public virtual methods whose name and signature
match a virtual method on the interface, then add these to the list for that
method, in type declaration order (see above).
If there are any public virtual methods available on this class (directly or inherited)
having the same name and signature as the interface method, and whose generic type
parameters do not exactly match any methods in the existing list for that interface
method for this class or any class in its inheritance chain, then add them (in type
declaration order) to the list for the corresponding methods on the interface.
II.15.2 Static, instance, and virtual methods
It follows that instance methods shall only be defined in classes or value types,
but not in interfaces or outside of a type (i.e., globally).
II.22.27 MethodImpl : 0x19
The method indexed by MethodBody shall be a member of Class or some base class
of Class (MethodImpls do not allow compilers to ‘hook’ arbitrary method bodies)
II.22.37 TypeDef : 0x02
All of the methods owned by an Interface (Flags.Interface = 1) shall be abstract
(Flags.Abstract = 1)
IV.6 Implementation-specific modifications to the system libraries
Interfaces and virtual methods shall not be added to an existing interface.
8 changes: 5 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisCSharpCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisElfieVersion>0.10.6</MicrosoftCodeAnalysisElfieVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.14</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisTestResourcesProprietaryVersion>2.0.15</MicrosoftCodeAnalysisTestResourcesProprietaryVersion>
<MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>$(MicrosoftCodeAnalysisTestingVersion)</MicrosoftCodeAnalysisVisualBasicCodeFixTestingXUnitVersion>
<MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>$(CodeStyleAnalyzerVersion)</MicrosoftCodeAnalysisVisualBasicCodeStyleVersion>
<MicrosoftCodeQualityAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftCodeQualityAnalyzersVersion>
Expand All @@ -69,9 +69,10 @@
<MicrosoftMSXMLVersion>8.0.0.0-alpha</MicrosoftMSXMLVersion>
<MicrosoftNetCompilersToolsetVersion>3.1.0-beta1-19164-01</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCoreAnalyzersVersion>$(RoslynDiagnosticsNugetPackageVersion)</MicrosoftNetCoreAnalyzersVersion>
<MicrosoftNetCoreILAsmVersion>2.0.0</MicrosoftNetCoreILAsmVersion>
<MicrosoftNetCoreILAsmVersion>3.0.0-preview4-27525-72</MicrosoftNetCoreILAsmVersion>
<MicrosoftNetCoreILAsmVersion>3.0.0-preview4-27525-72</MicrosoftNetCoreILAsmVersion>
<MicrosoftNetCoreILDasmVersion>3.0.0-preview4-27525-72</MicrosoftNetCoreILDasmVersion>
<MicrosoftNETCorePlatformsVersion>2.1.2</MicrosoftNETCorePlatformsVersion>
<MicrosoftNETCoreRuntimeCoreCLRVersion>2.0.0</MicrosoftNETCoreRuntimeCoreCLRVersion>
<!-- Using a private build of Microsoft.Net.Test.SDK to work around issue https://github.com/Microsoft/vstest/issues/1764 -->
<MicrosoftNETTestSdkVersion>15.9.0-dev2</MicrosoftNETTestSdkVersion>
<MicrosoftNETCoreTestHostVersion>1.1.0</MicrosoftNETCoreTestHostVersion>
Expand Down Expand Up @@ -317,6 +318,7 @@
https://vside.myget.org/F/vs-impl/api/v3/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
https://dotnet.myget.org/F/system-commandline/api/v3/index.json;
https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json;
</RestoreSources>
</PropertyGroup>
</Project>
3 changes: 2 additions & 1 deletion eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ function BuildSolution() {
# an arcade bug
# https://github.com/dotnet/arcade/issues/2220
$quietRestore = !($ci -or ($bootstrapDir -ne ""))
$testTargetFrameworks = if ($testCoreClr) { "netcoreapp2.1" } else { "" }
$testTargetFrameworks = if ($testCoreClr) { "netcoreapp3.0%3Bnetcoreapp2.1" } else { "" }

$ibcSourceBranchName = GetIbcSourceBranchName
$ibcDropId = if ($officialIbcDropId -ne "default") { $officialIbcDropId } else { "" }

Expand Down
2 changes: 1 addition & 1 deletion eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function BuildSolution {
mono_tool="/p:MonoTool=\"$mono_path\""
elif [[ "$test_core_clr" == true ]]; then
test=true
test_runtime="/p:TestRuntime=Core"
test_runtime="/p:TestRuntime=Core /p:TestTargetFrameworks=netcoreapp3.0%3Bnetcoreapp2.1"
mono_tool=""
fi

Expand Down
2 changes: 1 addition & 1 deletion eng/targets/Imports.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<!-- Only generate our runtimeconfig.json files for net core apps. It's unnecessary in desktop projects
but gets included in lots of output items like VSIX. -->
<GenerateRuntimeConfigurationFiles Condition="'$(TargetFramework)' != 'netcoreapp1.1' AND '$(TargetFramework)' != 'netcoreapp2.1'">false</GenerateRuntimeConfigurationFiles>
<GenerateRuntimeConfigurationFiles Condition="'$(TargetFramework)' != 'netcoreapp1.1' AND '$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp3.0'">false</GenerateRuntimeConfigurationFiles>

<!-- Place VS insertion (CoreXT) packages to a separate directory -->
<PackageOutputPath Condition="'$(IsVisualStudioInsertionPackage)' == 'true'">$(DevDivPackagesDir)</PackageOutputPath>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "3.0.100-preview3-010431",
"dotnet": "3.0.100-preview4-010963",
"vs": {
"version": "16.0"
},
Expand Down
Loading

0 comments on commit c420bea

Please sign in to comment.