Skip to content

Commit 788024a

Browse files
authored
Merge pull request #38991 from dotnet/merges/master-to-features/local-function-attributes
Merge master to features/local-function-attributes
2 parents 1b97910 + f8b94e8 commit 788024a

27 files changed

+304
-304
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## API Review Notes for September 30th, 2019
2+
3+
### Changes reviewed
4+
Starting commit: `12b125030c34e340086b7fa192fb9426aaddf054`
5+
6+
Ending Commit: `38c90f8401f9e3ee5fb7c82aac36f6b85fdda979`
7+
8+
### Notes
9+
10+
For the AnalyzerConfig removals, we've said that we're fine with this change because the API was just published, and wasn't intended to be.
11+
We don't want to maintain the API shape in the future, and we're willing to accept the risk of breaks in order to remove it now, before many people can take a hard dependency on the API surface.
12+
13+
ErrorLogPath removed from CommandLineArguments, moved to ErrorLogOptions.Path
14+
- We should maintain this API.
15+
- Just forward to the old implementation.
16+
- @333fred will send a PR.
17+
18+
TextDocument
19+
- Should we not remove the constructor? This is a binary breaking change
20+
- This empty constructor cannot be used.
21+
- We'll keep the change.
22+
23+
Workspace
24+
- CanApplyParseOptionChange going from virtual protected to virtual public is a source and binary breaking change
25+
- We should look at having a new non-virtual public method on Workspace and forward to this API.
26+
- @jasonmalinowski will look at this fix.
27+
28+
SyntaxFactory.AnonymousMethodExpression
29+
- Added overload with multiple parameters.
30+
- Part of https://github.com/dotnet/roslyn/pull/37674, which brings the API in line with MethodBodySyntax.
31+
This change is fine.
32+
33+
Formatter.OrganizeUsings
34+
- Should make cancellationtoken optional?
35+
- Need to followup with framework on what the current guidelines are
36+
- Make this default for now
37+
- @jasonmalinowski to follow up.
38+

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<ProductDependencies>
44
</ProductDependencies>
55
<ToolsetDependencies>
6-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19477.2">
6+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19480.3">
77
<Uri>https://github.com/dotnet/arcade</Uri>
8-
<Sha>14abaee3dba41fbe608431fb6a4f4b2435dcac33</Sha>
8+
<Sha>238f1bbb23ba67616818d0b242c5b55a18edec55</Sha>
99
</Dependency>
1010
</ToolsetDependencies>
1111
</Dependencies>

eng/Versions.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@
259259
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.NavigateTo.Interfaces" />
260260
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.Language.StandardClassification" />
261261
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LanguageServer.Client" />
262-
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LanguageServer.Protocol" />
263-
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LanguageServer.Protocol.Extensions" />
264262
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LiveShare.LanguageServices.Guest" />
265263
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.LiveShare.WebEditors" />
266264
<PrivateVisualStudioPackage Include="Microsoft.VisualStudio.OLE.Interop" />

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"xcopy-msbuild": "16.3.0-alpha"
88
},
99
"msbuild-sdks": {
10-
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19477.2"
10+
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19480.3"
1111
}
1212
}

src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11467,6 +11467,71 @@ public void AnalyzerWarnAsErrorDoesNotEmit(bool warnAsError)
1146711467
string binaryPath = Path.Combine(dir.Path, "temp.dll");
1146811468
Assert.True(File.Exists(binaryPath) == !warnAsError);
1146911469
}
11470+
11471+
// Currently, configuring no location diagnostics through editorconfig is not supported.
11472+
[Theory(Skip = "https://github.com/dotnet/roslyn/issues/38042")]
11473+
[CombinatorialData]
11474+
public void AnalyzerConfigRespectedForNoLocationDiagnostic(ReportDiagnostic reportDiagnostic, bool isEnabledByDefault, bool noWarn)
11475+
{
11476+
var analyzer = new AnalyzerWithNoLocationDiagnostics(isEnabledByDefault);
11477+
TestAnalyzerConfigRespectedCore(analyzer, analyzer.Descriptor, reportDiagnostic, noWarn);
11478+
}
11479+
11480+
[WorkItem(37876, "https://github.com/dotnet/roslyn/issues/37876")]
11481+
[Theory]
11482+
[CombinatorialData]
11483+
public void AnalyzerConfigRespectedForDisabledByDefaultDiagnostic(ReportDiagnostic analyzerConfigSeverity, bool isEnabledByDefault, bool noWarn)
11484+
{
11485+
var analyzer = new NamedTypeAnalyzerWithConfigurableEnabledByDefault(isEnabledByDefault);
11486+
TestAnalyzerConfigRespectedCore(analyzer, analyzer.Descriptor, analyzerConfigSeverity, noWarn);
11487+
}
11488+
11489+
private void TestAnalyzerConfigRespectedCore(DiagnosticAnalyzer analyzer, DiagnosticDescriptor descriptor, ReportDiagnostic analyzerConfigSeverity, bool noWarn)
11490+
{
11491+
if (analyzerConfigSeverity == ReportDiagnostic.Default)
11492+
{
11493+
// "dotnet_diagnostic.ID.severity = default" is not supported.
11494+
return;
11495+
}
11496+
11497+
var dir = Temp.CreateDirectory();
11498+
var src = dir.CreateFile("test.cs").WriteAllText(@"class C { }");
11499+
var analyzerConfig = dir.CreateFile(".editorconfig").WriteAllText($@"
11500+
[*.cs]
11501+
dotnet_diagnostic.{descriptor.Id}.severity = {analyzerConfigSeverity.ToAnalyzerConfigString()}");
11502+
11503+
var arguments = new[] {
11504+
"/nologo",
11505+
"/t:library",
11506+
"/preferreduilang:en",
11507+
"/analyzerconfig:" + analyzerConfig.Path,
11508+
src.Path };
11509+
if (noWarn)
11510+
{
11511+
arguments = arguments.Append($"/nowarn:{descriptor.Id}");
11512+
}
11513+
11514+
var cmd = CreateCSharpCompiler(null, dir.Path, arguments,
11515+
analyzers: ImmutableArray.Create<DiagnosticAnalyzer>(analyzer));
11516+
11517+
Assert.Equal(analyzerConfig.Path, Assert.Single(cmd.Arguments.AnalyzerConfigPaths));
11518+
11519+
var outWriter = new StringWriter(CultureInfo.InvariantCulture);
11520+
var exitCode = cmd.Run(outWriter);
11521+
11522+
var expectedErrorCode = analyzerConfigSeverity == ReportDiagnostic.Error ? 1 : 0;
11523+
Assert.Equal(expectedErrorCode, exitCode);
11524+
11525+
if (analyzerConfigSeverity == ReportDiagnostic.Error || analyzerConfigSeverity == ReportDiagnostic.Warn || analyzerConfigSeverity == ReportDiagnostic.Info)
11526+
{
11527+
var prefix = analyzerConfigSeverity == ReportDiagnostic.Error ? "error" : analyzerConfigSeverity == ReportDiagnostic.Warn ? "warning" : "info";
11528+
Assert.Contains($"{prefix} {descriptor.Id}: {descriptor.MessageFormat}", outWriter.ToString());
11529+
}
11530+
else
11531+
{
11532+
Assert.DoesNotContain(descriptor.Id.ToString(), outWriter.ToString());
11533+
}
11534+
}
1147011535
}
1147111536

1147211537
[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)]

src/Compilers/CSharp/Test/CommandLine/Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<ItemGroup>
2424
<EmbeddedResource Include="..\..\csc\csc.rsp" LogicalName="csc.rsp" />
2525
</ItemGroup>
26+
<ItemGroup>
27+
<PackageReference Include="Xunit.Combinatorial" Version="$(XunitCombinatorialVersion)" />
28+
</ItemGroup>
2629
<ItemGroup>
2730
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
2831
</ItemGroup>

src/Compilers/Core/MSBuildTask/Microsoft.CSharp.Core.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
44
<Import Project="Microsoft.Managed.Core.targets"/>
55

6-
<PropertyGroup Condition="('$(TargetFrameworkIdentifier)' != '.NETCoreApp' OR '$(TargetFrameworkVersion)' != 'v3.0') AND
7-
('$(TargetFrameworkIdentifier)' != '.NETStandard' OR '$(TargetFrameworkVersion)' != 'v2.1')">
6+
<PropertyGroup Condition="('$(TargetFrameworkIdentifier)' != '.NETCoreApp' OR '$(_TargetFrameworkVersionWithoutV)' &lt; '3.0') AND
7+
('$(TargetFrameworkIdentifier)' != '.NETStandard' OR '$(_TargetFrameworkVersionWithoutV)' &lt; '2.1')">
88
<MaxSupportedLangVersion Condition="'$(MaxSupportedLangVersion)' == ''">7.3</MaxSupportedLangVersion>
99
<LangVersion Condition="'$(LangVersion)' == ''">$(MaxSupportedLangVersion)</LangVersion>
1010
</PropertyGroup>

src/Compilers/Core/Portable/CommandLine/CommandLineArguments.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ public abstract class CommandLineArguments
127127
/// </summary>
128128
#nullable enable
129129
public ErrorLogOptions? ErrorLogOptions { get; internal set; }
130+
131+
/// <summary>
132+
/// Options controlling the generation of a SARIF log file containing compilation or
133+
/// analysis diagnostics, or null if no log file is desired.
134+
/// </summary>
135+
public string? ErrorLogPath => ErrorLogOptions?.Path;
130136
#nullable restore
131137

132138
/// <summary>

src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerManager.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,19 @@ internal bool IsDiagnosticAnalyzerSuppressed(
308308
// Is this diagnostic suppressed by default (as written by the rule author)
309309
var isSuppressed = !diag.IsEnabledByDefault;
310310

311-
// If the user said something about it, that overrides the author.
311+
// Compilation wide user settings from ruleset/nowarn/warnaserror overrides the analyzer author.
312312
if (diagnosticOptions.TryGetValue(diag.Id, out var severity))
313313
{
314314
isSuppressed = severity == ReportDiagnostic.Suppress;
315315
}
316316

317+
// Editorconfig user settings override compilation wide settings.
318+
if (isSuppressed &&
319+
isEnabledWithAnalyzerConfigOptions(diag.Id, analyzerExecutor.Compilation))
320+
{
321+
isSuppressed = false;
322+
}
323+
317324
if (!isSuppressed)
318325
{
319326
return false;
@@ -332,6 +339,23 @@ internal bool IsDiagnosticAnalyzerSuppressed(
332339
}
333340

334341
return true;
342+
343+
static bool isEnabledWithAnalyzerConfigOptions(string diagnosticId, Compilation compilation)
344+
{
345+
if (compilation != null)
346+
{
347+
foreach (var tree in compilation.SyntaxTrees)
348+
{
349+
if (tree.DiagnosticOptions.TryGetValue(diagnosticId, out var configuredValue) &&
350+
configuredValue != ReportDiagnostic.Suppress)
351+
{
352+
return true;
353+
}
354+
}
355+
}
356+
357+
return false;
358+
}
335359
}
336360

337361
internal static bool HasNotConfigurableTag(IEnumerable<string> customTags)

src/EditorFeatures/CSharpTest/DisposeAnalysis/DisposableFieldsShouldBeDisposedTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.DisposeAnalysis
1717
public sealed class DisposableFieldsShouldBeDisposedTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
1818
{
1919
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
20-
=> (new DisposableFieldsShouldBeDisposedDiagnosticAnalyzer(), null);
20+
=> (new DisposableFieldsShouldBeDisposedDiagnosticAnalyzer(isEnabledByDefault: true), null);
2121

2222
private Task TestDiagnosticsAsync(string initialMarkup, params DiagnosticDescription[] expectedDiagnostics)
2323
=> TestDiagnosticsAsync(initialMarkup, parseOptions: null, expectedDiagnostics);

0 commit comments

Comments
 (0)