Skip to content

Commit e699d73

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merges/master-to-features/local-function-attributes
2 parents 678010d + edd063a commit e699d73

File tree

58 files changed

+784
-168
lines changed

Some content is hidden

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

58 files changed

+784
-168
lines changed

Compilers.sln

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 15
3-
VisualStudioVersion = 15.0.27102.0
2+
# Visual Studio Version 16
3+
VisualStudioVersion = 16.0.29519.87
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.UnitTests", "src\Compilers\Core\CodeAnalysisTest\Microsoft.CodeAnalysis.UnitTests.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
66
EndProject
@@ -160,6 +160,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildBoss", "src\Tools\Buil
160160
EndProject
161161
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Net.Compilers.Toolset.Package", "src\NuGet\Microsoft.Net.Compilers.Toolset\Microsoft.Net.Compilers.Toolset.Package.csproj", "{6D407402-CC4A-4125-9B00-C70562A636A5}"
162162
EndProject
163+
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "vbi", "src\Interactive\vbi\vbi.vbproj", "{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}"
164+
EndProject
163165
Global
164166
GlobalSection(SharedMSBuildProjectFiles) = preSolution
165167
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
@@ -435,6 +437,10 @@ Global
435437
{6D407402-CC4A-4125-9B00-C70562A636A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
436438
{6D407402-CC4A-4125-9B00-C70562A636A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
437439
{6D407402-CC4A-4125-9B00-C70562A636A5}.Release|Any CPU.Build.0 = Release|Any CPU
440+
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
441+
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Debug|Any CPU.Build.0 = Debug|Any CPU
442+
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Release|Any CPU.ActiveCfg = Release|Any CPU
443+
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Release|Any CPU.Build.0 = Release|Any CPU
438444
EndGlobalSection
439445
GlobalSection(SolutionProperties) = preSolution
440446
HideSolutionNode = FALSE
@@ -508,6 +514,7 @@ Global
508514
{B446E771-AB52-41C9-ACFC-FDF8EACAF291} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
509515
{8A02AFAF-F622-4E3E-9E1A-8CFDACC7C7E1} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
510516
{6D407402-CC4A-4125-9B00-C70562A636A5} = {274B96B7-F815-47E3-9CA4-4024A57A478F}
517+
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87} = {3FF38FD4-DF16-44B0-924F-0D5AE155495B}
511518
EndGlobalSection
512519
GlobalSection(ExtensibilityGlobals) = postSolution
513520
SolutionGuid = {6F599E08-A9EA-4FAA-897F-5D824B0210E6}

src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/CSharpResources.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5090,6 +5090,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
50905090
<data name="ERR_SwitchCaseSubsumed" xml:space="preserve">
50915091
<value>The switch case has already been handled by a previous case.</value>
50925092
</data>
5093+
<data name="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected" xml:space="preserve">
5094+
<value>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</value>
5095+
</data>
50935096
<data name="ERR_SwitchArmSubsumed" xml:space="preserve">
50945097
<value>The pattern has already been handled by a previous arm of the switch expression.</value>
50955098
</data>
@@ -5999,4 +6002,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
59996002
<data name="ERR_ImplicitRangeIndexerWithName" xml:space="preserve">
60006003
<value>Invocation of implicit Range Indexer cannot name the argument.</value>
60016004
</data>
6002-
</root>
6005+
</root>

src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
224224
{
225225
case "-": // csi -- script.csx
226226
if (value != null) break;
227+
if (arg == "-")
228+
{
229+
if (Console.IsInputRedirected)
230+
{
231+
sourceFiles.Add(new CommandLineSourceFile("-", isScript: true, isInputRedirected: true));
232+
sourceFilesSpecified = true;
233+
}
234+
else
235+
{
236+
AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
237+
}
238+
continue;
239+
}
227240

228241
// Indicates that the remaining arguments should not be treated as options.
229242
optionsEnded = true;
@@ -1260,6 +1273,18 @@ internal sealed override CommandLineArguments CommonParse(IEnumerable<string> ar
12601273
embeddedFiles.Add(ToCommandLineSourceFile(path));
12611274
}
12621275
continue;
1276+
1277+
case "-":
1278+
if (Console.IsInputRedirected)
1279+
{
1280+
sourceFiles.Add(new CommandLineSourceFile("-", isScript: false, isInputRedirected: true));
1281+
sourceFilesSpecified = true;
1282+
}
1283+
else
1284+
{
1285+
AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
1286+
}
1287+
continue;
12631288
}
12641289
}
12651290

src/Compilers/CSharp/Portable/CommandLine/CSharpCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public override Compilation CreateCompilation(
109109
{
110110
var normalizedFilePath = normalizedFilePaths[i];
111111
Debug.Assert(normalizedFilePath != null);
112-
Debug.Assert(PathUtilities.IsAbsolute(normalizedFilePath));
112+
Debug.Assert(sourceFiles[i].IsInputRedirected || PathUtilities.IsAbsolute(normalizedFilePath));
113113

114114
if (!uniqueFilePaths.Add(normalizedFilePath))
115115
{

src/Compilers/CSharp/Portable/Errors/ErrorCode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,8 @@ internal enum ErrorCode
17581758

17591759
WRN_DoesNotReturnMismatch = 8771,
17601760

1761+
ERR_StdInOptionProvidedButConsoleInputIsNotRedirected = 8782,
1762+
17611763
// Note: you will need to re-generate compiler code after adding warnings (eng\generate-compiler-code.cmd)
17621764
}
17631765
}

src/Compilers/CSharp/Portable/Parser/LanguageParser.cs

Lines changed: 77 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,7 @@ private void ParseBlockAndExpressionBodiesWithSemicolon(
24502450

24512451
if (this.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
24522452
{
2453-
blockBody = this.ParseBlock(attributes: default, isMethodBody: true);
2453+
blockBody = this.ParseMethodOrAccessorBodyBlock(attributes: default, isAccessorBody: false);
24542454
}
24552455

24562456
if (this.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
@@ -3286,7 +3286,7 @@ private AccessorDeclarationSyntax ParseAccessorDeclaration(bool isEvent)
32863286
{
32873287
if (!IsTerminator())
32883288
{
3289-
blockBody = this.ParseBlock(attributes: default, isMethodBody: true, isAccessorBody: true);
3289+
blockBody = this.ParseMethodOrAccessorBodyBlock(attributes: default, isAccessorBody: true);
32903290
}
32913291
else
32923292
{
@@ -6423,8 +6423,10 @@ private StatementSyntax TryParseStatementNoDeclaration(
64236423
case SyntaxKind.GotoKeyword:
64246424
return this.ParseGotoStatement(attributes);
64256425
case SyntaxKind.IfKeyword:
6426-
case SyntaxKind.ElseKeyword: // Including 'else' keyword to handle 'else without if' error cases
64276426
return this.ParseIfStatement(attributes);
6427+
case SyntaxKind.ElseKeyword:
6428+
// Including 'else' keyword to handle 'else without if' error cases
6429+
return this.ParseMisplacedElse(attributes);
64286430
case SyntaxKind.LockKeyword:
64296431
return this.ParseLockStatement(attributes);
64306432
case SyntaxKind.ReturnKeyword:
@@ -6947,59 +6949,72 @@ private bool IsPossibleNewExpression()
69476949
return null;
69486950
}
69496951

6950-
private BlockSyntax ParsePossiblyAttributedBlock(bool isMethodBody = false, bool isAccessorBody = false)
6951-
=> ParseBlock(this.ParseAttributeDeclarations(), isMethodBody, isAccessorBody);
6952+
private BlockSyntax ParsePossiblyAttributedBlock() => ParseBlock(this.ParseAttributeDeclarations());
69526953

6953-
// If "isMethodBody" is true, then this is the immediate body of a method/accessor.
6954-
// In this case, we create a many-child list if the body is not a small single statement.
6955-
// This then allows a "with many weak children" red node when the red node is created.
6956-
// If "isAccessorBody" is true, then we produce a special diagnostic if the open brace is
6957-
// missing. Also, "isMethodBody" must be true.
6958-
private BlockSyntax ParseBlock(SyntaxList<AttributeListSyntax> attributes, bool isMethodBody = false, bool isAccessorBody = false)
6954+
/// <summary>
6955+
/// Used to parse the block-body for a method or accessor. For blocks that appear *inside*
6956+
/// method bodies, call <see cref="ParseBlock"/>.
6957+
/// </summary>
6958+
/// <param name="isAccessorBody">If is true, then we produce a special diagnostic if the
6959+
/// open brace is missing.</param>
6960+
private BlockSyntax ParseMethodOrAccessorBodyBlock(SyntaxList<AttributeListSyntax> attributes, bool isAccessorBody)
69596961
{
6960-
// Check again for incremental re-use, since ParseBlock is called from a bunch of places
6961-
// other than ParseStatementCore()
6962+
// Check again for incremental re-use. This way if a method signature is edited we can
6963+
// still quickly re-sync on the body.
69626964
if (this.IsIncrementalAndFactoryContextMatches &&
69636965
this.CurrentNodeKind == SyntaxKind.Block &&
69646966
attributes.Count == 0)
6965-
{
69666967
return (BlockSyntax)this.EatNode();
6967-
}
69686968

69696969
// There's a special error code for a missing token after an accessor keyword
6970-
var openBrace = isAccessorBody && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken
6970+
CSharpSyntaxNode openBrace = isAccessorBody && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken
69716971
? this.AddError(
69726972
SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken),
69736973
IsFeatureEnabled(MessageID.IDS_FeatureExpressionBodiedAccessor)
6974-
? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
6975-
: ErrorCode.ERR_SemiOrLBraceExpected)
6974+
? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
6975+
: ErrorCode.ERR_SemiOrLBraceExpected)
69766976
: this.EatToken(SyntaxKind.OpenBraceToken);
69776977

69786978
var statements = _pool.Allocate<StatementSyntax>();
6979-
try
6980-
{
6981-
CSharpSyntaxNode tmp = openBrace;
6982-
this.ParseStatements(ref tmp, statements, stopOnSwitchSections: false);
6983-
openBrace = (SyntaxToken)tmp;
6984-
var closeBrace = this.EatToken(SyntaxKind.CloseBraceToken);
6979+
this.ParseStatements(ref openBrace, statements, stopOnSwitchSections: false);
69856980

6986-
SyntaxList<StatementSyntax> statementList;
6987-
if (isMethodBody && IsLargeEnoughNonEmptyStatementList(statements))
6988-
{
6989-
// Force creation a many-children list, even if only 1, 2, or 3 elements in the statement list.
6990-
statementList = new SyntaxList<StatementSyntax>(SyntaxList.List(((SyntaxListBuilder)statements).ToArray()));
6991-
}
6992-
else
6993-
{
6994-
statementList = statements;
6995-
}
6981+
var block = _syntaxFactory.Block(
6982+
attributes,
6983+
(SyntaxToken)openBrace,
6984+
// Force creation a many-children list, even if only 1, 2, or 3 elements in the statement list.
6985+
IsLargeEnoughNonEmptyStatementList(statements)
6986+
? new SyntaxList<StatementSyntax>(SyntaxList.List(((SyntaxListBuilder)statements).ToArray()))
6987+
: statements,
6988+
this.EatToken(SyntaxKind.CloseBraceToken));
69966989

6997-
return _syntaxFactory.Block(attributes, openBrace, statementList, closeBrace);
6998-
}
6999-
finally
7000-
{
7001-
_pool.Free(statements);
7002-
}
6990+
_pool.Free(statements);
6991+
return block;
6992+
}
6993+
6994+
/// <summary>
6995+
/// Used to parse normal blocks that appear inside method bodies. For the top level block
6996+
/// of a method/accessor use <see cref="ParseMethodOrAccessorBodyBlock"/>.
6997+
/// </summary>
6998+
private BlockSyntax ParseBlock(SyntaxList<AttributeListSyntax> attributes)
6999+
{
7000+
// Check again for incremental re-use, since ParseBlock is called from a bunch of places
7001+
// other than ParseStatementCore()
7002+
if (this.IsIncrementalAndFactoryContextMatches && this.CurrentNodeKind == SyntaxKind.Block)
7003+
return (BlockSyntax)this.EatNode();
7004+
7005+
CSharpSyntaxNode openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
7006+
7007+
var statements = _pool.Allocate<StatementSyntax>();
7008+
this.ParseStatements(ref openBrace, statements, stopOnSwitchSections: false);
7009+
7010+
var block = _syntaxFactory.Block(
7011+
attributes,
7012+
(SyntaxToken)openBrace,
7013+
statements,
7014+
this.EatToken(SyntaxKind.CloseBraceToken));
7015+
7016+
_pool.Free(statements);
7017+
return block;
70037018
}
70047019

70057020
// Is this statement list non-empty, and large enough to make using weak children beneficial?
@@ -7703,21 +7718,30 @@ private GotoStatementSyntax ParseGotoStatement(SyntaxList<AttributeListSyntax> a
77037718

77047719
private IfStatementSyntax ParseIfStatement(SyntaxList<AttributeListSyntax> attributes)
77057720
{
7706-
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.IfKeyword || this.CurrentToken.Kind == SyntaxKind.ElseKeyword);
7721+
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.IfKeyword);
77077722

7708-
bool firstTokenIsElse = this.CurrentToken.Kind == SyntaxKind.ElseKeyword;
7709-
var @if = firstTokenIsElse
7710-
? this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement)
7711-
: this.EatToken(SyntaxKind.IfKeyword);
7712-
var openParen = this.EatToken(SyntaxKind.OpenParenToken);
7713-
var condition = this.ParseExpressionCore();
7714-
var closeParen = this.EatToken(SyntaxKind.CloseParenToken);
7715-
var statement = firstTokenIsElse
7716-
? this.ParseExpressionStatement(attributes: default)
7717-
: this.ParseEmbeddedStatement();
7718-
var elseClause = this.ParseElseClauseOpt();
7723+
return _syntaxFactory.IfStatement(
7724+
attributes,
7725+
this.EatToken(SyntaxKind.IfKeyword),
7726+
this.EatToken(SyntaxKind.OpenParenToken),
7727+
this.ParseExpressionCore(),
7728+
this.EatToken(SyntaxKind.CloseParenToken),
7729+
this.ParseEmbeddedStatement(),
7730+
this.ParseElseClauseOpt());
7731+
}
77197732

7720-
return _syntaxFactory.IfStatement(attributes, @if, openParen, condition, closeParen, statement, elseClause);
7733+
private IfStatementSyntax ParseMisplacedElse(SyntaxList<AttributeListSyntax> attributes)
7734+
{
7735+
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.ElseKeyword);
7736+
7737+
return _syntaxFactory.IfStatement(
7738+
attributes,
7739+
this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement),
7740+
this.EatToken(SyntaxKind.OpenParenToken),
7741+
this.ParseExpressionCore(),
7742+
this.EatToken(SyntaxKind.CloseParenToken),
7743+
this.ParseExpressionStatement(attributes: default),
7744+
this.ParseElseClauseOpt());
77217745
}
77227746

77237747
private ElseClauseSyntax ParseElseClauseOpt()

src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@
437437
<target state="translated">Statický člen {0} se nedá označit modifikátorem readonly.</target>
438438
<note />
439439
</trans-unit>
440+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
441+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
442+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
443+
<note />
444+
</trans-unit>
440445
<trans-unit id="ERR_SwitchArmSubsumed">
441446
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
442447
<target state="translated">Tento vzor už zpracovala předchozí větev výrazu switch.</target>
@@ -9860,4 +9865,4 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference
98609865
</trans-unit>
98619866
</body>
98629867
</file>
9863-
</xliff>
9868+
</xliff>

src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@
437437
<target state="translated">Der statische Member "{0}" kann nicht als "readonly" markiert werden.</target>
438438
<note />
439439
</trans-unit>
440+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
441+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
442+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
443+
<note />
444+
</trans-unit>
440445
<trans-unit id="ERR_SwitchArmSubsumed">
441446
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
442447
<target state="translated">Das Muster wurde bereits durch einen vorherigen Zweig des switch-Ausdrucks verarbeitet.</target>
@@ -9860,4 +9865,4 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett
98609865
</trans-unit>
98619866
</body>
98629867
</file>
9863-
</xliff>
9868+
</xliff>

src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@
437437
<target state="translated">El miembro estático "{0}" no se puede marcar como "readonly".</target>
438438
<note />
439439
</trans-unit>
440+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
441+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
442+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
443+
<note />
444+
</trans-unit>
440445
<trans-unit id="ERR_SwitchArmSubsumed">
441446
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
442447
<target state="translated">El patrón ya se ha controlado con una parte anterior de la expresión switch.</target>
@@ -9860,4 +9865,4 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe
98609865
</trans-unit>
98619866
</body>
98629867
</file>
9863-
</xliff>
9868+
</xliff>

0 commit comments

Comments
 (0)