Skip to content

Commit 37d3667

Browse files
Merge remote-tracking branch 'upstream/main' into inlineHintDuplicate
2 parents 1e21020 + a9cafab commit 37d3667

File tree

170 files changed

+2612
-2466
lines changed

Some content is hidden

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

170 files changed

+2612
-2466
lines changed

azure-pipelines-official.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ extends:
121121
displayName: Build and Test
122122

123123
jobs:
124-
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/release/dev17.12') }}:
124+
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/release/dev17.13') }}:
125125
- template: /eng/common/templates-official/job/onelocbuild.yml@self
126126
parameters:
127127
MirrorRepo: roslyn
128-
MirrorBranch: release/dev17.12
128+
MirrorBranch: release/dev17.13
129129
LclSource: lclFilesfromPackage
130130
LclPackageId: 'LCL-JUNO-PROD-ROSLYN'
131131

docs/features/incremental-generators.cookbook.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ public class FileTransformGenerator : IIncrementalGenerator
208208
}
209209
```
210210

211+
Items need to be included in your csproj files by using the `AdditionalFiles` ItemGroup:
212+
213+
```xml
214+
<ItemGroup>
215+
<AdditionalFiles Include="file1.xml" />
216+
<AdditionalFiles Include="file2.xml" />
217+
<ItemGroup>
218+
```
219+
211220
### Augment user code
212221

213222
**User scenario:** As a generator author I want to be able to inspect and augment a user's code with new functionality.

src/Analyzers/Core/Analyzers/RemoveUnusedMembers/AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using System.Linq;
1111
using System.Runtime.CompilerServices;
1212
using System.Threading;
13-
using Microsoft.CodeAnalysis.CodeQuality;
1413
using Microsoft.CodeAnalysis.CodeStyle;
1514
using Microsoft.CodeAnalysis.Diagnostics;
1615
using Microsoft.CodeAnalysis.LanguageService;
@@ -27,10 +26,9 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer<
2726
TIdentifierNameSyntax,
2827
TTypeDeclarationSyntax,
2928
TMemberDeclarationSyntax>()
30-
: AbstractCodeQualityDiagnosticAnalyzer(
29+
: AbstractBuiltInUnnecessaryCodeStyleDiagnosticAnalyzer(
3130
[s_removeUnusedMembersRule, s_removeUnreadMembersRule],
32-
// We want to analyze references in generated code, but not report unused members in generated code.
33-
GeneratedCodeAnalysisFlags.Analyze)
31+
FadingOptions.FadeOutUnusedMembers)
3432
where TDocumentationCommentTriviaSyntax : SyntaxNode
3533
where TIdentifierNameSyntax : SyntaxNode
3634
where TTypeDeclarationSyntax : TMemberDeclarationSyntax
@@ -44,35 +42,43 @@ internal abstract class AbstractRemoveUnusedMembersDiagnosticAnalyzer<
4442
memberOptions: SymbolDisplayMemberOptions.IncludeContainingType);
4543

4644
// IDE0051: "Remove unused members" (Symbol is declared but never referenced)
47-
private static readonly DiagnosticDescriptor s_removeUnusedMembersRule = CreateDescriptor(
45+
private static readonly DiagnosticDescriptor s_removeUnusedMembersRule = CreateDescriptorWithId(
4846
IDEDiagnosticIds.RemoveUnusedMembersDiagnosticId,
4947
EnforceOnBuildValues.RemoveUnusedMembers,
48+
hasAnyCodeStyleOption: false,
5049
new LocalizableResourceString(nameof(AnalyzersResources.Remove_unused_private_members), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
5150
new LocalizableResourceString(nameof(AnalyzersResources.Private_member_0_is_unused), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
52-
hasAnyCodeStyleOption: false, isUnnecessary: true);
51+
isUnnecessary: true);
5352

5453
// IDE0052: "Remove unread members" (Value is written and/or symbol is referenced, but the assigned value is never read)
5554
// Internal for testing
56-
internal static readonly DiagnosticDescriptor s_removeUnreadMembersRule = CreateDescriptor(
55+
internal static readonly DiagnosticDescriptor s_removeUnreadMembersRule = CreateDescriptorWithId(
5756
IDEDiagnosticIds.RemoveUnreadMembersDiagnosticId,
5857
EnforceOnBuildValues.RemoveUnreadMembers,
58+
hasAnyCodeStyleOption: false,
5959
new LocalizableResourceString(nameof(AnalyzersResources.Remove_unread_private_members), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
6060
new LocalizableResourceString(nameof(AnalyzersResources.Private_member_0_can_be_removed_as_the_value_assigned_to_it_is_never_read), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
61-
hasAnyCodeStyleOption: false, isUnnecessary: true);
61+
isUnnecessary: true);
6262

6363
protected abstract ISemanticFacts SemanticFacts { get; }
6464

6565
protected abstract IEnumerable<TTypeDeclarationSyntax> GetTypeDeclarations(INamedTypeSymbol namedType, CancellationToken cancellationToken);
6666
protected abstract SyntaxList<TMemberDeclarationSyntax> GetMembers(TTypeDeclarationSyntax typeDeclaration);
6767
protected abstract SyntaxNode GetParentIfSoleDeclarator(SyntaxNode declaration);
6868

69-
// We need to analyze the whole document even for edits within a method body,
70-
// because we might add or remove references to members in executable code.
71-
// For example, if we had an unused field with no references, then editing any single method body
72-
// to reference this field should clear the unused field diagnostic.
73-
// Hence, we need to re-analyze the declarations in the whole file for any edits within the document.
69+
/// <summary>
70+
/// We need to analyze the whole document even for edits within a method body, because we might add or remove
71+
/// references to members in executable code. For example, if we had an unused field with no references, then
72+
/// editing any single method body to reference this field should clear the unused field diagnostic. Hence, we need
73+
/// to re-analyze the declarations in the whole file for any edits within the document.
74+
/// </summary>
7475
public override DiagnosticAnalyzerCategory GetAnalyzerCategory() => DiagnosticAnalyzerCategory.SemanticDocumentAnalysis;
7576

77+
/// <summary>
78+
/// We want to analyze references in generated code, but not report unused members in generated code.
79+
/// </summary>
80+
protected override GeneratedCodeAnalysisFlags GeneratedCodeAnalysisFlags => GeneratedCodeAnalysisFlags.Analyze;
81+
7682
protected sealed override void InitializeWorker(AnalysisContext context)
7783
=> context.RegisterCompilationStartAction(compilationStartContext
7884
=> CompilationAnalyzer.CreateAndRegisterActions(compilationStartContext, this));

src/Analyzers/VisualBasic/Tests/RemoveUnusedMembers/RemoveUnusedMembersTests.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ parseOptions:=Nothing,
16211621
compilationOptions:=Nothing,
16221622
options:=Nothing,
16231623
"IDE0051",
1624-
DiagnosticSeverity.Info,
1624+
DiagnosticSeverity.Hidden,
16251625
diagnosticMessage:=String.Format(AnalyzersResources.Private_member_0_is_unused, "C.New"))
16261626
End Function
16271627
End Class

src/EditorFeatures/CSharp/EndConstruct/CSharpEndConstructGenerationService.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,21 @@
66
using System.Composition;
77
using System.Diagnostics.CodeAnalysis;
88
using System.Threading;
9+
using System.Threading.Tasks;
910
using Microsoft.CodeAnalysis.Editor.Implementation.EndConstructGeneration;
1011
using Microsoft.CodeAnalysis.Host.Mef;
1112
using Microsoft.VisualStudio.Text;
1213
using Microsoft.VisualStudio.Text.Editor;
14+
using Roslyn.Utilities;
1315

1416
namespace Microsoft.CodeAnalysis.Editor.CSharp.EndConstructGeneration;
1517

1618
[ExportLanguageService(typeof(IEndConstructGenerationService), LanguageNames.CSharp), Shared]
1719
[ExcludeFromCodeCoverage]
18-
internal class CSharpEndConstructGenerationService : IEndConstructGenerationService
20+
[method: ImportingConstructor]
21+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
22+
internal sealed class CSharpEndConstructGenerationService() : IEndConstructGenerationService
1923
{
20-
[ImportingConstructor]
21-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
22-
public CSharpEndConstructGenerationService()
23-
{
24-
}
25-
26-
public bool TryDo(
27-
ITextView textView,
28-
ITextBuffer subjectBuffer,
29-
char typedChar,
30-
CancellationToken cancellationToken)
31-
{
32-
return false;
33-
}
24+
public Task<bool> TryDoAsync(ITextView textView, ITextBuffer subjectBuffer, char typedChar, CancellationToken cancellationToken)
25+
=> SpecializedTasks.False;
3426
}

0 commit comments

Comments
 (0)