Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master to features/module-initializers #45271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
ee2e8a0
Always construct mocks as strict
sharwell Apr 30, 2020
4a0252e
Fix incorrect mock setup
sharwell Apr 30, 2020
66ec80f
Update BannedSymbols.txt to require strict mocks
sharwell Apr 30, 2020
9d0655e
Initial changes to help with profiling
CyrusNajmabadi May 28, 2020
04b4d29
Add navto benchmark
CyrusNajmabadi May 29, 2020
c5f2778
Attempting to fix rebase issues
allisonchou Jun 5, 2020
d605109
rename for clarity
CyrusNajmabadi Jun 6, 2020
66f8dd2
Don't use extensions for private members
CyrusNajmabadi Jun 6, 2020
345d920
Inline method
CyrusNajmabadi Jun 6, 2020
9e27ea9
Simplify with an asynclazy.
CyrusNajmabadi Jun 6, 2020
f6b8f78
in progress
CyrusNajmabadi Jun 8, 2020
c187cfa
Merge remote-tracking branch 'upstream/master' into perfFar
CyrusNajmabadi Jun 8, 2020
209b6d7
Update test
CyrusNajmabadi Jun 8, 2020
6c89e5c
Current work
CyrusNajmabadi Jun 8, 2020
5d99faa
delete these
CyrusNajmabadi Jun 8, 2020
7c8c197
Merge remote-tracking branch 'upstream/master' into depProjFinder
CyrusNajmabadi Jun 8, 2020
80ae6e5
REfactoring
CyrusNajmabadi Jun 8, 2020
a9c79b6
fast ivt
CyrusNajmabadi Jun 8, 2020
b954d77
Merge branch 'perfFar' into depProjFinderPerf
CyrusNajmabadi Jun 8, 2020
f3ecdf4
Fixes
CyrusNajmabadi Jun 8, 2020
ec3d96e
Revert
CyrusNajmabadi Jun 8, 2020
cfc1f41
Revert
CyrusNajmabadi Jun 8, 2020
bb678d9
Simplify
CyrusNajmabadi Jun 8, 2020
0bb1ded
Fixes
CyrusNajmabadi Jun 8, 2020
60cc32e
Initial tests
CyrusNajmabadi Jun 8, 2020
149f4ca
Add tests.
CyrusNajmabadi Jun 8, 2020
da37f20
temp
CyrusNajmabadi Jun 8, 2020
a1b9adf
Simplify
CyrusNajmabadi Jun 8, 2020
4e35211
Lint
CyrusNajmabadi Jun 8, 2020
0204116
revert
CyrusNajmabadi Jun 8, 2020
0f20f1d
Revert
CyrusNajmabadi Jun 8, 2020
a31623f
Simplify
CyrusNajmabadi Jun 8, 2020
7d9567d
Allow explicit construction of a loose mock
sharwell Jun 8, 2020
adc248e
Simplify
CyrusNajmabadi Jun 8, 2020
ac631c0
Simplify
CyrusNajmabadi Jun 8, 2020
526b03e
Simplify
CyrusNajmabadi Jun 8, 2020
412ed5d
Move back for PR
CyrusNajmabadi Jun 8, 2020
dd70ba6
Remove
CyrusNajmabadi Jun 8, 2020
7504784
Doc
CyrusNajmabadi Jun 8, 2020
d90c762
Move back
CyrusNajmabadi Jun 8, 2020
fd24c10
REvert
CyrusNajmabadi Jun 9, 2020
4d60fac
Rollback
CyrusNajmabadi Jun 9, 2020
9461d4b
Merge remote-tracking branch 'dotnet/master' into strict-mocks
sharwell Jun 9, 2020
04d5720
Simplify
CyrusNajmabadi Jun 9, 2020
03ec4c3
Inline
CyrusNajmabadi Jun 9, 2020
db8fe71
Inline
CyrusNajmabadi Jun 9, 2020
728187a
Use IActiveStatementSpanTracker through MEF
sharwell Jun 7, 2020
ea75bfb
Merge branch 'master' of github.com:dotnet/roslyn into DuplicateDiagn…
allisonchou Jun 9, 2020
307e695
Change RichNav to run daily
xuachen Jun 9, 2020
7f8fdad
Include no triggers
xuachen Jun 9, 2020
c39cf0e
use ConvertedType instead of Type to determine if param array has bee…
sigmachirality Jun 9, 2020
dd35065
correct array syntax in ParamsObjectArray test
sigmachirality Jun 9, 2020
5aeded2
add StringArray test
sigmachirality Jun 9, 2020
b288e8f
add LiteralArray test
sigmachirality Jun 9, 2020
7e4665d
Apply #44854 to preview3 branch
RikkiGibson Jun 9, 2020
b97c2ce
Merge branch 'release/dev16.7-preview3' of github.com:dotnet/roslyn i…
RikkiGibson Jun 10, 2020
8c06e22
Update the baseline...again
RikkiGibson Jun 10, 2020
31a883f
Remove IActiveStatementSpanTracker from the MEF catalog
sharwell Jun 10, 2020
7e3dd03
Merge pull request #45011 from RikkiGibson/fix-stack-p3
RikkiGibson Jun 10, 2020
18e2a83
Theme the move to namespace dialog
ryzngard Jun 10, 2020
db44df3
Keep 3 most recent items at top
ryzngard Jun 10, 2020
de34e36
Fix diagnostic for mixed partial type (#45025)
jcouv Jun 10, 2020
adde59e
Fix hanging tests
allisonchou Jun 10, 2020
d67d239
Make VisualStudioDebuggeeModuleMetadataProvider lazy
genlu Jun 10, 2020
036a548
Add historic data to the VS implementation of MoveToNamespace
ryzngard Jun 10, 2020
a84e986
Clean up code a little
ryzngard Jun 10, 2020
2b5266f
Only send relevant completion resolve parameters
dibarbet Jun 11, 2020
12fbed0
Implement IEquatable<T> in record types (#44994)
cston Jun 11, 2020
1386401
Docs
CyrusNajmabadi Jun 11, 2020
519d25d
Docs
CyrusNajmabadi Jun 11, 2020
9155823
Rename
CyrusNajmabadi Jun 11, 2020
38bbdf9
Docs
CyrusNajmabadi Jun 11, 2020
d083e1a
Fix spelling
CyrusNajmabadi Jun 11, 2020
3f5de78
Merge branch 'master' into fix_deserialization_resolve
dibarbet Jun 11, 2020
c480fe9
use null-coalescing assignment
genlu Jun 11, 2020
615b3c0
Simplify with pattern matching
CyrusNajmabadi Jun 11, 2020
5cc698b
Exclude entry points from unused members analysis
sharwell Jun 11, 2020
cb0be79
Target Remote.Workspaces to .NET Core 3.1
genlu Jun 11, 2020
0415d00
Merge pull request #45089 from CyrusNajmabadi/patternMatching
Jun 11, 2020
a04b7d3
Adjust baseline (#45085)
RikkiGibson Jun 11, 2020
a96b49c
Fix NRT warnings
genlu Jun 11, 2020
ce18b40
Merge pull request #45061 from genlu/MakeEncServiceLazy
genlu Jun 11, 2020
5f9ceb7
Add ProjectGuid and SolutionSessionId to API telemetry
JoeRobich Feb 5, 2020
110dd23
Add Constants for accessing SoutionSessionID
JoeRobich Feb 7, 2020
22b08f0
Fix spelling of Telemetry
JoeRobich Feb 7, 2020
427a164
Support pattern variables declared under "is not" (#44513)
Jun 12, 2020
9fe39d8
Support pattern variables declared under "is not" (#44513)
Jun 12, 2020
5f5c283
Merge pull request #45006 from xuachen/patch-4
jasonmalinowski Jun 12, 2020
2825a25
Adjust baseline (#45085)
RikkiGibson Jun 11, 2020
e180bdc
Reduce x86/Release baseline to try and make up for flakiness
RikkiGibson Jun 12, 2020
0ca5383
Use linked list
ryzngard Jun 12, 2020
3e9c9e8
Merge pull request #45091 from genlu/RemoteWorkspacesCore
genlu Jun 12, 2020
94c70eb
Record copy ctor must invoke base copy ctor (#45022)
jcouv Jun 12, 2020
3ddcdae
Handle new CPS analyzer node path format
drewnoakes Jun 12, 2020
b9f4db8
PR feedback
ryzngard Jun 12, 2020
b4e4528
Don't use Contains
ryzngard Jun 12, 2020
5cddfce
Merge pull request #45094 from gafter/dev16.7-preview3-44513
Jun 12, 2020
f943a1a
Merge pull request #45064 from ryzngard/issues/43086_recent_namespace…
Jun 12, 2020
6db6c5e
Merge pull request #45090 from sharwell/unused-main
sharwell Jun 12, 2020
c6f473f
Merge pull request #45004 from sharwell/use-mef-2
sharwell Jun 12, 2020
0abb1a6
add WorkItem attribute to new test
sigmachirality Jun 12, 2020
4f88176
add LiteralArray test to C# ValidateFormatString tests
sigmachirality Jun 12, 2020
4faa0bd
Merge remote-tracking branch 'upstream/release/dev16.7-preview3' into…
RikkiGibson Jun 12, 2020
1967d75
Merge pull request #44952 from CyrusNajmabadi/depProjFinder
CyrusNajmabadi Jun 12, 2020
3815a99
Remove caching
CyrusNajmabadi Jun 12, 2020
387ba58
Remove unnecessary types
CyrusNajmabadi Jun 12, 2020
a172b8d
Ignore errors getting TelemetryHelper
JoeRobich Jun 12, 2020
d83908d
Don't default classifications if colors have been customized
JoeRobich Jun 12, 2020
1422726
Update syntax and commment
allisonchou Jun 12, 2020
9f8603f
Merge pull request #43844 from sharwell/strict-mocks
sharwell Jun 12, 2020
7714ab4
Merge pull request #45048 from dotnet/merges/release/dev16.7-preview3…
RikkiGibson Jun 12, 2020
787426c
Fix typos (#44967)
cston Jun 12, 2020
e7663ec
Merge pull request #45007 from sigmachirality/FormatStringEdgeCase
CyrusNajmabadi Jun 13, 2020
18b41d0
Merge pull request #45118 from JoeRobich/dont-default-colors
JoeRobich Jun 13, 2020
fa1edb0
Fix MakeMethodAsynchronous on ValueTask without generics.
Kuinox Jun 13, 2020
8c3d23d
Merge pull request #45116 from CyrusNajmabadi/removeCaching2
CyrusNajmabadi Jun 13, 2020
c0c192d
Merge pull request #45150 from Kuinox/master
CyrusNajmabadi Jun 14, 2020
e1dcbb3
Merge pull request #45101 from drewnoakes/update-analyzer-node-file-path
drewnoakes Jun 14, 2020
b89ea39
Set telemetryId on remote solution and projects
JoeRobich Jun 14, 2020
6db1b7a
Merge pull request #41443 from JoeRobich/add-telemetry-ids
JoeRobich Jun 15, 2020
c2912f6
Merge pull request #44874 from allisonchou/DuplicateDiagnosticsLSP
allisonchou Jun 15, 2020
ef50fde
Update dependencies from https://github.com/dotnet/roslyn build 20200…
dotnet-maestro[bot] Jun 15, 2020
c16f7d8
Assert our tests don't accidentally have compiler errors in them
jasonmalinowski Jun 12, 2020
6b954a1
If you forget a Language attribute, give a useful message
jasonmalinowski Jun 12, 2020
3917656
Don't generate references for built-in operators
jasonmalinowski Jun 12, 2020
77ef532
Merge pull request #45068 from dibarbet/fix_deserialization_resolve
dibarbet Jun 15, 2020
5dbf9b1
Merge pull request #45125 from jasonmalinowski/do-not-generate-refere…
Jun 15, 2020
85b65a4
Disallow 'with' in expression trees (#45095)
jcouv Jun 15, 2020
b9ffafd
Fix crash in 'replace property with methods' when updating object ini…
CyrusNajmabadi Jun 16, 2020
fe44abf
Update src/Compilers/VisualBasic/Portable/Syntax/SyntaxFactory.vb
CyrusNajmabadi Jun 16, 2020
e666b94
Simplify
CyrusNajmabadi Jun 16, 2020
b126556
NRT and immutable array
CyrusNajmabadi Jun 16, 2020
edc8449
Merge branch 'replacePropCrash' of https://github.com/CyrusNajmabadi/…
CyrusNajmabadi Jun 16, 2020
c7f09a2
Only warnAsError in correctness (#44261)
RikkiGibson Jun 16, 2020
64b18be
Add some tests (#45230)
AlekseyTs Jun 16, 2020
1fd21f8
Make Inheritance_* tests contiguous (#45233)
cston Jun 16, 2020
38efd87
Merge pull request #45231 from CyrusNajmabadi/replacePropCrash
Jun 16, 2020
6e07682
Import all custom modifiers and move their validation to compilers. (…
AlekseyTs Jun 16, 2020
88dd4bb
Implement SemanticModel.GetConversion for switch expressions. (#45069)
Jun 16, 2020
2ad1435
Fix a crash when a nullable reference type is used in a pattern. (#45…
Jun 17, 2020
d702fa6
Handle custom modifiers on copy ctor (#45136)
jcouv Jun 17, 2020
d04ebc2
Revert "Remove IActiveStatementSpanTracker from the MEF catalog" (#45…
chsienki Jun 17, 2020
d957f3e
Implement val escape for switch expressions (#45242)
Jun 17, 2020
d09d7ab
Merge branch 'features/module-initializers' into merges/master-to-fea…
RikkiGibson Jun 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions azure-pipelines-richnav.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Run on master CI builds
trigger:
trigger: none
pr: none

schedules:
- cron: "0 0 * * *"
displayName: Daily midnight (UTC) RichNav indexer run
branches:
include:
- master

pr: none

jobs:
- job: RichCodeNav_Indexing
pool:
Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>9b71be0663493cd0e111b55536a2e1eeb272f54c</Sha>
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.7.0-2.20267.1">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.7.0-4.20314.5">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>3126e7a9753bf09a99e4c4f152b8dfef76862dc5</Sha>
<Sha>c2835e1b5cdb18dba1edb7991942abb68ba1b83f</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</MajorVersion>
<MinorVersion>
</MinorVersion>
<MicrosoftNetCompilersToolsetVersion>3.7.0-2.20267.1</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetVersion>3.7.0-4.20314.5</MicrosoftNetCompilersToolsetVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Versions used by several individual references below -->
Expand Down
4 changes: 1 addition & 3 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ function BuildSolution() {

# The warnAsError flag for MSBuild will promote all warnings to errors. This is true for warnings
# that MSBuild output as well as ones that custom tasks output.
#
# In all cases we pass /p:TreatWarningsAsErrors=true to promote compiler warnings to errors
$msbuildWarnAsError = if ($warnAsError) { "/warnAsError" } else { "" }

# Workaround for some machines in the AzDO pool not allowing long paths (%5c is msbuild escaped backslash)
Expand Down Expand Up @@ -255,7 +253,7 @@ function BuildSolution() {
/p:UseRoslynAnalyzers=$runAnalyzers `
/p:BootstrapBuildPath=$bootstrapDir `
/p:TestTargetFrameworks=$testTargetFrameworks `
/p:TreatWarningsAsErrors=true `
/p:TreatWarningsAsErrors=$warnAsError `
/p:EnableNgenOptimization=$applyOptimizationData `
/p:IbcOptimizationDataDir=$ibcDir `
$restoreUseStaticGraphEvaluation `
Expand Down
1 change: 1 addition & 0 deletions eng/config/test/BannedSymbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M:Moq.Mock`1.#ctor; Pass MockBehavior.Strict explicitly to the constructor for Mock<T>
5 changes: 5 additions & 0 deletions eng/targets/XUnit.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<PrepareForBuildDependsOn>$(PrepareForBuildDependsOn);AddDefaultTestAppConfig</PrepareForBuildDependsOn>
</PropertyGroup>

<ItemGroup>
<!-- Include BannedSymbols covering all test projects -->
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\config\test\BannedSymbols.txt" />
</ItemGroup>

<!-- Add a default test app.config, if the project doesn't already have one-->
<Target Name="AddDefaultTestAppConfig">
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void InitializeWorker(AnalysisContext context)
private sealed class SymbolAnalyzer
{
private readonly INamedTypeSymbol _namedTypeSymbol;
private bool _hasTypeInstanceAssigment;
private bool _hasTypeInstanceAssignment;

private SymbolAnalyzer(INamedTypeSymbol namedTypeSymbol)
=> _namedTypeSymbol = namedTypeSymbol;
Expand Down Expand Up @@ -99,13 +99,13 @@ private void AnalyzeAssignment(OperationAnalysisContext context)
var operationAssigmnent = (IAssignmentOperation)context.Operation;
if (operationAssigmnent.Target is IInstanceReferenceOperation { ReferenceKind: InstanceReferenceKind.ContainingTypeInstance })
{
Volatile.Write(ref _hasTypeInstanceAssigment, true);
Volatile.Write(ref _hasTypeInstanceAssignment, true);
}
}

private void SymbolEndAction(SymbolAnalysisContext context)
{
if (_hasTypeInstanceAssigment)
if (_hasTypeInstanceAssignment)
{
var diagnostic = Diagnostic.Create(
s_diagnosticDescriptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.RemoveUnusedMembers;
using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Testing;
using Roslyn.Test.Utilities;
Expand Down Expand Up @@ -356,6 +358,113 @@ class MyClass
await VerifyCS.VerifyCodeFixAsync(code, code);
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task EntryPointMethodNotFlagged_06()
{
var code = @"
return 0;
";

await new VerifyCS.Test
{
TestCode = code,
FixedCode = code,
ExpectedDiagnostics =
{
// error CS8805: Program using top-level statements must be an executable.
DiagnosticResult.CompilerError("CS8805"),
},
LanguageVersion = LanguageVersionExtensions.CSharp9,
}.RunAsync();
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task EntryPointMethodNotFlagged_07()
{
var code = @"
return 0;
";

await new VerifyCS.Test
{
TestState =
{
Sources = { code, code },
},
FixedState =
{
Sources = { code, code },
},
ExpectedDiagnostics =
{
// error CS8805: Program using top-level statements must be an executable.
DiagnosticResult.CompilerError("CS8805"),
// /0/Test1.cs(2,1): error CS8802: Only one compilation unit can have top-level statements.
DiagnosticResult.CompilerError("CS8802").WithSpan("/0/Test1.cs", 2, 1, 2, 7),
},
LanguageVersion = LanguageVersionExtensions.CSharp9,
}.RunAsync();
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task EntryPointMethodNotFlagged_08()
{
var code = @"
return 0;
";

await new VerifyCS.Test
{
TestCode = code,
FixedCode = code,
SolutionTransforms =
{
(solution, projectId) =>
{
var project = solution.GetRequiredProject(projectId);
var compilationOptions = project.CompilationOptions;
return solution.WithProjectCompilationOptions(projectId, compilationOptions.WithOutputKind(OutputKind.ConsoleApplication));
},
},
LanguageVersion = LanguageVersionExtensions.CSharp9,
}.RunAsync();
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task EntryPointMethodNotFlagged_09()
{
var code = @"
return 0;
";

await new VerifyCS.Test
{
TestState =
{
Sources = { code, code },
},
FixedState =
{
Sources = { code, code },
},
ExpectedDiagnostics =
{
// /0/Test1.cs(2,1): error CS8802: Only one compilation unit can have top-level statements.
DiagnosticResult.CompilerError("CS8802").WithSpan("/0/Test1.cs", 2, 1, 2, 7),
},
SolutionTransforms =
{
(solution, projectId) =>
{
var project = solution.GetRequiredProject(projectId);
var compilationOptions = project.CompilationOptions;
return solution.WithProjectCompilationOptions(projectId, compilationOptions.WithOutputKind(OutputKind.ConsoleApplication));
},
},
LanguageVersion = LanguageVersionExtensions.CSharp9,
}.RunAsync();
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnusedMembers)]
public async Task FieldIsUnused_ReadOnly()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ static void Main(string[] args)
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.ValidateFormatString)]
public async Task LiteralArray()
{
await TestDiagnosticMissingAsync(@" class Program
{
static void Main(string[] args)
{
string.Format(""This {0[||]} {1} {2} {3} works"", new [] {""test1"", ""test2"", ""test3"", ""test4""});
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.ValidateFormatString)]
public async Task StringArrayOutOfBounds_NoDiagnostic()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,16 @@ private void OnSymbolEnd(SymbolAnalysisContext symbolEndContext, bool hasUnsuppo
ArrayBuilder<string> debuggerDisplayAttributeArguments = null;
try
{
var entryPoint = symbolEndContext.Compilation.GetEntryPoint(symbolEndContext.CancellationToken);

var namedType = (INamedTypeSymbol)symbolEndContext.Symbol;
foreach (var member in namedType.GetMembers())
{
if (SymbolEqualityComparer.Default.Equals(entryPoint, member))
{
continue;
}

// Check if the underlying member is neither read nor a readable reference to the member is taken.
// If so, we flag the member as either unused (never written) or unread (written but not read).
if (TryRemove(member, out var valueUsageInfo) &&
Expand Down Expand Up @@ -689,7 +696,7 @@ private bool IsCandidateSymbol(ISymbol memberSymbol)
}

private bool IsEntryPoint(IMethodSymbol methodSymbol)
=> methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName &&
=> (methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName || methodSymbol.Name == "$Main") &&
methodSymbol.IsStatic &&
(methodSymbol.ReturnsVoid ||
methodSymbol.ReturnType.SpecialType == SpecialType.System_Int32 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private bool ArgsIsArrayOfReferenceTypes(
}

var expression = syntaxFacts.GetExpressionOfArgument(argsArgument);
return semanticModel.GetTypeInfo(expression).Type;
return semanticModel.GetTypeInfo(expression).ConvertedType;
}

protected SyntaxNode? TryGetArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,33 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ValidateFormatStri
End Function

<Fact, Trait(Traits.Feature, Traits.Features.ValidateFormatString)>
Public Async Function ParamsObjectArray() As Task
Public Async Function ObjectArray() As Task
Await TestDiagnosticMissingAsync("
Class C
Sub Main
string.Format(""This {0} {1} {[||]2} works"", New Object { ""test"", ""test2"", ""test3"" })
string.Format(""This {0} {1} {[||]2} works"", New Object() { ""test"", ""test2"", ""test3"" })
End Sub
End Class")
End Function

<WorkItem(42764, "https://github.com/dotnet/roslyn/issues/42764")>
<Fact, Trait(Traits.Feature, Traits.Features.ValidateFormatString)>
Public Async Function LiteralArray() As Task
Await TestDiagnosticMissingAsync("
Class C
Sub Main
string.Format(""This {0[||]} {1} {2} {3} works"", { ""test"", ""test2"", ""test3"", ""test4"" })
End Sub
End Class")
End Function

<Fact, Trait(Traits.Feature, Traits.Features.ValidateFormatString)>
Public Async Function StringArray() As Task
Await TestDiagnosticMissingAsync("
Class C
Sub Main
Dim strings() = {""test"", ""test2""}
String.Format(""This {0} {[||]1} works"", strings)
End Sub
End Class")
End Function
Expand Down
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ internal bool CheckValueKind(SyntaxNode node, BoundExpression expr, BindValueKin

case BoundKind.IndexOrRangePatternIndexerAccess:
var patternIndexer = (BoundIndexOrRangePatternIndexerAccess)expr;
// If we got here this should be a pttern indexer taking a Range,
// If we got here this should be a pattern indexer taking a Range,
// meaning that the pattern symbol must be a method (either Slice or Substring)
return CheckMethodReturnValueKind(
(MethodSymbol)patternIndexer.PatternSymbol,
Expand Down Expand Up @@ -2569,6 +2569,11 @@ internal static uint GetValEscape(BoundExpression expr, uint scopeOfTheContainin
// only possible in error cases (if possible at all)
return scopeOfTheContainingExpression;

case BoundKind.ConvertedSwitchExpression:
case BoundKind.UnconvertedSwitchExpression:
var switchExpr = (BoundSwitchExpression)expr;
return GetValEscape(switchExpr.SwitchArms.SelectAsArray(a => a.Value), scopeOfTheContainingExpression);

default:
// in error situations some unexpected nodes could make here
// returning "scopeOfTheContainingExpression" seems safer than throwing.
Expand Down
7 changes: 4 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ private BoundExpression BindObjectCreationExpression(BoundUnconvertedObjectCreat
private BoundExpression ConvertSwitchExpression(BoundUnconvertedSwitchExpression source, TypeSymbol destination, Conversion? conversionIfTargetTyped, DiagnosticBag diagnostics, bool hasErrors = false)
{
bool targetTyped = conversionIfTargetTyped != null;
Conversion conversion = conversionIfTargetTyped ?? Conversion.Identity;
Debug.Assert(targetTyped || destination.IsErrorType() || destination.Equals(source.Type, TypeCompareKind.ConsiderEverything));
ImmutableArray<Conversion> underlyingConversions = conversionIfTargetTyped.GetValueOrDefault().UnderlyingConversions;
ImmutableArray<Conversion> underlyingConversions = conversion.UnderlyingConversions;
var builder = ArrayBuilder<BoundSwitchExpressionArm>.GetInstance(source.SwitchArms.Length);
for (int i = 0, n = source.SwitchArms.Length; i < n; i++)
{
Expand All @@ -244,7 +245,7 @@ private BoundExpression ConvertSwitchExpression(BoundUnconvertedSwitchExpression

var newSwitchArms = builder.ToImmutableAndFree();
return new BoundConvertedSwitchExpression(
source.Syntax, source.Type, targetTyped, source.Expression, newSwitchArms, source.DecisionDag,
source.Syntax, source.Type, targetTyped, conversion, source.Expression, newSwitchArms, source.DecisionDag,
source.DefaultLabel, source.ReportedNotExhaustive, destination, hasErrors || source.HasErrors);
}

Expand Down Expand Up @@ -912,7 +913,7 @@ internal bool MethodIsCompatibleWithDelegateOrFunctionPointer(BoundExpression? r
// * Every value parameter (non-ref or similar) from the delegate type has an implicit conversion to the corresponding
// target parameter
// * Every ref or similar parameter has an identity conversion to the corresponding target parameter
// However, the delegate compatiblity requirements are stricter:
// However, the delegate compatibility requirements are stricter:
// * Every value parameter (non-ref or similar) from the delegate type has an implicit _reference_ conversion to the
// corresponding target parameter.
// * Every ref or similar parameter has an identity conversion to the corresponding target parameter
Expand Down
Loading