Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into merges/main-to-feat…
Browse files Browse the repository at this point in the history
…ures/required-members

* upstream/main: (73 commits)
  Allow source link, embedded or decompiled source in Peek Definition (#61427)
  More instrumentation for ReferenceCachingCS (#61402)
  Fix build
  Fix binding for checkbox text in rename dialogs (#61430)
  Address feedback from numeric IntPtr feature review (#61418)
  [LSP] Small cleanup for pull diagnostics logging (#61417)
  Avoid logging work when no logger is specified
  Wait for async operations to complete before proceeding
  Fix function id (#61400)
  More correctly respect background analysis scope (#61392)
  Add new collapsing option for metadata files that contain source (#61205)
  Fix typo (#61380)
  Use AspNetCoreKey to external access assembly
  Update src/Features/Core/Portable/InheritanceMargin/AbstractInheritanceMarginService_Helpers.cs
  Update src/Features/Core/Portable/InheritanceMargin/AbstractInheritanceMarginService_Helpers.cs
  Parse `unchecked` gracefully in operators (#61309)
  Add lambda parameters in scope in nameof using proper binder (#61382)
  Verify classification on var pattern (#61376)
  Verifying interpolation escaping of curlies in content (#61387)
  Fix
  ...
  • Loading branch information
333fred committed May 23, 2022
2 parents cb14f67 + 038b1a9 commit e9c411e
Show file tree
Hide file tree
Showing 944 changed files with 37,578 additions and 13,139 deletions.
35 changes: 34 additions & 1 deletion docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
# This document lists known breaking changes in Roslyn after .NET 6 all the way to .NET 7.

## Checked operators on System.IntPtr and System.UIntPtr

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

When the platform supports __numeric__ `IntPtr` and `UIntPtr` types (as indicated by the presence of
`System.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr`) the built-in operators from `nint`
and `nuint` apply to those underlying types.
This means that on such platforms, `IntPtr` and `UIntPtr` have built-in `checked` operators, which
can now throw when an overflow occurs.

```csharp
IntPtr M(IntPtr x, int y)
{
checked
{
return x + y; // may now throw
}
}

unsafe IntPtr M2(void* ptr)
{
return checked((IntPtr)ptr); // may now throw
}
```

Possible workarounds are:

1. Specify `unchecked` context
2. Downgrade to a platform/TFM without numeric `IntPtr`/`UIntPtr` types

Also, implicit conversions between `IntPtr`/`UIntPtr` and other numeric types are treated as standard
conversions on such platforms. This can affect overload resolution in some cases.

## Nameof operator in attribute on method or local function

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

When the language version is C# 11 or later, a `nameof` operator in an attribute on a method
brings the type parameters of that method in scope. The same applies for local functions.
Expand Down
3 changes: 3 additions & 0 deletions eng/config/BannedSymbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ M:Microsoft.CodeAnalysis.QuickInfo.QuickInfoService.GetQuickInfoAsync(Microsoft.
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Document,System.Nullable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
M:Microsoft.CodeAnalysis.CodeFixes.FixAllContext.#ctor(Microsoft.CodeAnalysis.Project,Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider,Microsoft.CodeAnalysis.CodeFixes.FixAllScope,System.String,System.Collections.Generic.IEnumerable{System.String},Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider,System.Threading.CancellationToken); Use internal overload instead
M:Microsoft.CodeAnalysis.Document.GetOptionsAsync(System.Threading.CancellationToken); Use Document.GetAnalyzerConfigOptionsAsync instead
T:Microsoft.CodeAnalysis.Options.DocumentOptionSet; Use AnalyzerConfigOptions instead
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetService``2(System.IServiceProvider); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing.
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetService``2(System.IServiceProvider,System.Boolean); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing
M:Microsoft.VisualStudio.Shell.ServiceExtensions.GetServiceAsync``2(Microsoft.VisualStudio.Shell.IAsyncServiceProvider); Use RoslynServiceExtensions instead. This extension internally relies on ThreadHelper, which is incompatible with testing
Expand All @@ -25,6 +27,7 @@ M:Microsoft.CodeAnalysis.Formatting.Formatter.Format(Microsoft.CodeAnalysis.Synt
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
M:Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattedTextChanges(Microsoft.CodeAnalysis.SyntaxNode,System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.Text.TextSpan},Microsoft.CodeAnalysis.Workspace,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload with SyntaxFormattingOptions instead
M:Microsoft.CodeAnalysis.Formatting.Formatter.OrganizeImportsAsync(Microsoft.CodeAnalysis.Document,System.Threading.CancellationToken); Call IOrganizeImportsService.OrganizeImportsAsync directly
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.SyntaxAnnotation,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
M:Microsoft.CodeAnalysis.Simplification.Simplifier.ReduceAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.Text.TextSpan,Microsoft.CodeAnalysis.Options.OptionSet,System.Threading.CancellationToken); Use overload that takes SimplifierOptions
Expand Down
2 changes: 1 addition & 1 deletion eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<!-- VB specific settings -->
<When Condition="'$(Language)' == 'VB'">
<PropertyGroup>
<LangVersion>16</LangVersion>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);40057</NoWarn>
<VBRuntime>Embed</VBRuntime>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ protected override void InitializeWorker(AnalysisContext context)
public void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
var statement = context.Node;
var cancellationToken = context.CancellationToken;

var option = context.Options.GetOption(CSharpCodeStyleOptions.PreferBraces, statement.SyntaxTree, cancellationToken);
var option = context.GetCSharpAnalyzerOptions().PreferBraces;
if (option.Value == PreferBracesPreference.None)
{
return;
Expand Down Expand Up @@ -102,7 +101,7 @@ public void AnalyzeNode(SyntaxNodeAnalysisContext context)
return;
}

if (ContainsInterleavedDirective(statement, embeddedStatement, cancellationToken))
if (ContainsInterleavedDirective(statement, embeddedStatement, context.CancellationToken))
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Compile Include="$(MSBuildThisFileDirectory)AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddRequiredParentheses\CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeStyle\CSharpAnalyzerOptionsProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertNamespace\ConvertNamespaceAnalysis.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertNamespace\ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertNamespace\ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs" />
Expand Down Expand Up @@ -60,7 +61,6 @@
<Compile Include="$(MSBuildThisFileDirectory)PopulateSwitch\CSharpPopulateSwitchStatementDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Simplification\CSharpSimplifierOptionsFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyBooleanExpression\CSharpSimplifyConditionalDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\CSharpSimplifyInterpolationHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplifyInterpolation\CSharpSimplifyInterpolationDiagnosticAnalyzer.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
<data name="Use_block_body_for_operators" xml:space="preserve">
<value>Use block body for operators</value>
</data>
<data name="Use_block_body_for_conversion_operators" xml:space="preserve">
<value>Use block body for conversion operators</value>
</data>
<data name="Use_block_body_for_properties" xml:space="preserve">
<value>Use block body for properties</value>
</data>
Expand All @@ -197,6 +200,9 @@
<data name="Use_expression_body_for_operators" xml:space="preserve">
<value>Use expression body for operators</value>
</data>
<data name="Use_expression_body_for_conversion_operators" xml:space="preserve">
<value>Use expression body for conversion operators</value>
</data>
<data name="Use_expression_body_for_properties" xml:space="preserve">
<value>Use expression body for properties</value>
</data>
Expand Down
Loading

0 comments on commit e9c411e

Please sign in to comment.