Skip to content

Commit

Permalink
Merge pull request #62300 from RikkiGibson/ft-update-from-main
Browse files Browse the repository at this point in the history
Update "file types" from main
  • Loading branch information
RikkiGibson committed Jul 1, 2022
2 parents fa2182b + 80bdf24 commit a540733
Show file tree
Hide file tree
Showing 1,107 changed files with 54,855 additions and 14,194 deletions.
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true

# Currently only enabled for C# due to crash in VB analyzer. VB can be enabled once
# https://github.com/dotnet/roslyn/pull/54259 has been published.
dotnet_style_allow_statement_immediately_after_block_experimental = false

[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}]

# IDE0011: Add braces
Expand Down
117 changes: 117 additions & 0 deletions azure-pipelines-compliance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Name: DotNet-Roslyn-Compliance
# URL: https://devdiv.visualstudio.com/DevDiv/_build?definitionId=16722
#
# Responsible for running compliance checks.

#
# NOTE: triggers for this build are defined in the Web UI instead of here in the YAML file so they
# apply to all branches.

queue:
name: VSEngSS-MicroBuild2022-1ES
demands: Cmd
timeoutInMinutes: 90
variables:
BuildConfiguration: Release
TeamName: DotNet-Roslyn
SignType: test
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
_DevDivDropAccessToken: $(System.AccessToken)

steps:
- template: eng/pipelines/checkout-windows-task.yml

- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
displayName: Setting SourceBranchName variable

- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(Build.BuildNumber)"
displayName: Setting VisualStudio.DropName variable

- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -ci
-restore
-build
-configuration $(BuildConfiguration)
-officialBuildId $(Build.BuildNumber)
-officialSkipTests true
-officialSkipApplyOptimizationData true
-officialSourceBranchName $(SourceBranchName)
-officialVisualStudioDropAccessToken $(_DevDivDropAccessToken)
/p:RepositoryName=$(Build.Repository.Name)
/p:VisualStudioDropName=$(VisualStudio.DropName)

- task: CopyFiles@2
# APIScan can take a long time, so here we copy (mostly) just the product binaries and related .pdbs
# in an effort to limit what it needs to work on.
displayName: Copy Roslyn assemblies for APIScan
inputs:
SourceFolder: '$(Build.SourcesDirectory)\artifacts\bin\Roslyn.VisualStudio.Setup\$(BuildConfiguration)\net472' # Limit to (mostly) product binaries
Contents: |
Microsoft.CodeAnalysis*.dll
Microsoft.CodeAnalysis*.pdb
Microsoft.VisualStudio.LanguageServices*.dll
Microsoft.VisualStudio.LanguageServices*.pdb
TargetFolder: '$(Agent.TempDirectory)\APIScanFiles'
continueOnError: true

- task: CopyFiles@2
displayName: Copy csc assemblies for APIScan
inputs:
SourceFolder: '$(Build.SourcesDirectory)\artifacts\bin\csc\$(BuildConfiguration)\net472'
Contents: |
csc.dll
csc.pdb
TargetFolder: '$(Agent.TempDirectory)\APIScanFiles'
continueOnError: true

- task: CopyFiles@2
displayName: Copy vbc assemblies for APIScan
inputs:
SourceFolder: '$(Build.SourcesDirectory)\artifacts\bin\vbc\$(BuildConfiguration)\net472'
Contents: |
vbc.dll
vbc.pdb
TargetFolder: '$(Agent.TempDirectory)\APIScanFiles'
continueOnError: true

- task: CopyFiles@2
displayName: Copy VBCSCompiler assemblies for APIScan
inputs:
SourceFolder: '$(Build.SourcesDirectory)\artifacts\bin\VBCSCompiler\$(BuildConfiguration)\net472'
Contents: |
VBCSCompiler.dll
VBCSCompiler.pdb
TargetFolder: '$(Agent.TempDirectory)\APIScanFiles'
continueOnError: true

- task: APIScan@2
# Scan for the use of undocumented APIs.
displayName: Run APIScan
inputs:
softwareFolder: '$(Agent.TempDirectory)\APIScanFiles' # Only examine the product binaries we previously copied.
softwareName: 'Dotnet-Roslyn'
softwareVersionNum: '17.0'
softwareBuildNum: '$(Build.BuildId)'
symbolsFolder: 'SRV*http://symweb'
env:
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(ApiScanSecret)
continueOnError: true

- task: TSAUpload@2
# Scan the output of previous steps and create bugs for any problems.
displayName: Upload results and create bugs
inputs:
GdnPublishTsaOnboard: true
GdnPublishTsaConfigFile: '$(Build.SourcesDirectory)\eng\TSAConfig.gdntsa' # All relevant settings are in this file.
continueOnError: true

- task: PublishSecurityAnalysisLogs@3
displayName: Publishing analysis artifacts
inputs:
ArtifactName: 'CodeAnalysisLogs'
ArtifactType: 'Container' # Associate the artifacts with the build.
AllTools: true # Look for logs from all tools.
ToolLogsNotFoundAction: 'Standard' # If a log is not found just output a message to that effect.
4 changes: 2 additions & 2 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ variables:
- name: Insertion.TitlePrefix
value: '[Auto Insertion]'
- name: Insertion.TitleSuffix
value: '[Skip-SymbolCheck]'
value: ''

stages:

Expand Down Expand Up @@ -314,7 +314,7 @@ stages:

- stage: insert
dependsOn:
- build
- publish_using_darc
displayName: Insert to VS

jobs:
Expand Down
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-task.yml
- template: eng/pipelines/checkout-windows-task.yml

- script: eng/test-determinism.cmd -configuration Debug
displayName: Build - Validate determinism
Expand All @@ -202,7 +202,7 @@ jobs:
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-task.yml
- template: eng/pipelines/checkout-windows-task.yml

- script: eng/test-build-correctness.cmd -configuration Release -enableDumps
displayName: Build - Validate correctness
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
vmImage: ubuntu-20.04
timeoutInMinutes: 10
steps:
- template: eng/pipelines/checkout-task.yml
- template: eng/pipelines/checkout-unix-task.yml

- pwsh: eng/todo-check.ps1
displayName: Validate TODO/PROTOTYPE comments are not present
Expand All @@ -244,7 +244,7 @@ jobs:
demands: ImageOverride -equals Build.Windows.Amd64.VS2022.Pre.Open
timeoutInMinutes: 90
steps:
- template: eng/pipelines/checkout-task.yml
- template: eng/pipelines/checkout-windows-task.yml

- task: PowerShell@2
displayName: Restore
Expand Down
2 changes: 1 addition & 1 deletion docs/Language Feature Status.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ efforts behind them.
| [Primary Constructors](https://github.com/dotnet/csharplang/issues/2691) | [primary-constructors](https://github.com/dotnet/roslyn/tree/features/primary-constructors) | [In Progress](https://github.com/dotnet/roslyn/issues/57048) | TBD | TBD | [MadsTorgersen](https://github.com/MadsTorgersen) |
| [Params Span\<T> + Stackalloc any array type](https://github.com/dotnet/csharplang/issues/1757) | [params-span](https://github.com/dotnet/roslyn/tree/features/params-span) | [In Progress](https://github.com/dotnet/roslyn/issues/57049) | [cston](https://github.com/cston) | TBD | [jaredpar](https://github.com/jaredpar) |
| [nameof accessing instance members](https://github.com/dotnet/roslyn/issues/40229) | main | [In Progress](https://github.com/dotnet/roslyn/pull/48754) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [333fred](https://github.com/333fred), [AlekseyTs](https://github.com/AlekseyTs) | [333fred](https://github.com/333fred) |
| [ref fields](https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md) | [ref-fields](https://github.com/dotnet/roslyn/tree/features/ref-fields) | [In Progress](https://github.com/dotnet/roslyn/issues/59194) | [cston](https://github.com/cston) | [RikkiGibson](https://github.com/RikkiGibson), [AlekseyTs](https://github.com/AlekseyTs) | [jaredpar](https://github.com/jaredpar) |
| [ref fields](https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md) | [ref-fields](https://github.com/dotnet/roslyn/tree/features/ref-fields) | [Merged into 17.3p3](https://github.com/dotnet/roslyn/issues/59194) | [cston](https://github.com/cston) | [RikkiGibson](https://github.com/RikkiGibson), [AlekseyTs](https://github.com/AlekseyTs) | [jaredpar](https://github.com/jaredpar) |
| [File types](https://github.com/dotnet/csharplang/issues/6011) | [file-types](https://github.com/dotnet/roslyn/tree/features/file-types) | [In Progress](https://github.com/dotnet/roslyn/issues/60819) | [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv), [cston](https://github.com/cston) | [stephentoub](https://github.com/stephentoub) |

# C# 10.0
Expand Down
65 changes: 65 additions & 0 deletions docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,71 @@ Note: The break will also apply to C# 10 and earlier when .NET 7 ships, but is
currently scoped down to users of LangVer=preview.
Tracked by https://github.com/dotnet/roslyn/issues/60640

## Cannot return an out parameter by reference

***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.***

With language version C# 11 or later, or with .NET 7.0 or later, an `out` parameter cannot be returned by reference.

```csharp
static ref T ReturnOutParamByRef<T>(out T t)
{
t = default;
return ref t; // error CS8166: Cannot return a parameter by reference 't' because it is not a ref parameter
}
```

A possible workaround is to change the method signature to pass the parameter by `ref` instead.

```csharp
static ref T ReturnRefParamByRef<T>(ref T t)
{
t = default;
return ref t; // ok
}
```

## Method ref struct return escape analysis depends on ref escape of ref arguments

***Introduced in .NET SDK 7.0.100, Visual Studio 2022 version 17.3.***

With language version C# 11 or later, or with .NET 7.0 or later, the return value of a method invocation that returns a `ref struct` is only _safe-to-escape_ if all the `ref` and `in` arguments to the method invocation are _ref-safe-to-escape_. _The `in` arguments may include implicit default parameter values._

```csharp
ref struct R { }

static R MayCaptureArg(ref int i) => new R();

static R MayCaptureDefaultArg(in int i = 0) => new R();

static R Create()
{
int i = 0;
// error CS8347: Cannot use a result of 'MayCaptureArg(ref int)' because it may expose
// variables referenced by parameter 'i' outside of their declaration scope
return MayCaptureArg(ref i);
}

static R CreateDefault()
{
// error CS8347: Cannot use a result of 'MayCaptureDefaultArg(in int)' because it may expose
// variables referenced by parameter 'i' outside of their declaration scope
return MayCaptureDefaultArg();
}
```

A possible workaround, if the `ref` or `in` argument is not captured in the `ref struct` return value, is to declare the parameter as `scoped ref` or `scoped in`.

```csharp
static R CannotCaptureArg(scoped ref int i) => new R();

static R Create()
{
int i = 0;
return CannotCaptureArg(ref i); // ok
}
```

## Unsigned right shift operator

***Introduced in .NET SDK 6.0.400, Visual Studio 2022 version 17.3.***
Expand Down
2 changes: 2 additions & 0 deletions docs/contributing/Compiler Test Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ This document provides guidance for thinking about language interactions and tes
- Compound operators (`+=`, `/=`, etc ..)
- Assignment exprs
- Ref return, ref readonly return, ref ternary, ref readonly local, ref local re-assignment, ref foreach
- Ref fields
- `scoped` parameters and locals
- `this = e;` in `struct` .ctor
- Stackalloc (including initializers)
- Patterns (constant, declaration, `var`, positional, property and extended property, discard, parenthesized, type, relational, `and`/`or`/`not`, list, slice, constant `string` matching `Span<char>`)
Expand Down
Loading

0 comments on commit a540733

Please sign in to comment.