Skip to content

Commit cfa22b5

Browse files
author
msftbot[bot]
authored
Merge pull request #41669 from dotnet/merges/master-to-master-vs-deps
Merge master to master-vs-deps
2 parents 9966bca + edd063a commit cfa22b5

File tree

58 files changed

+779
-183
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

+779
-183
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
@@ -5081,6 +5081,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
50815081
<data name="ERR_SwitchCaseSubsumed" xml:space="preserve">
50825082
<value>The switch case has already been handled by a previous case.</value>
50835083
</data>
5084+
<data name="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected" xml:space="preserve">
5085+
<value>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</value>
5086+
</data>
50845087
<data name="ERR_SwitchArmSubsumed" xml:space="preserve">
50855088
<value>The pattern has already been handled by a previous arm of the switch expression.</value>
50865089
</data>
@@ -5990,4 +5993,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
59905993
<data name="ERR_ImplicitRangeIndexerWithName" xml:space="preserve">
59915994
<value>Invocation of implicit Range Indexer cannot name the argument.</value>
59925995
</data>
5993-
</root>
5996+
</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
@@ -1756,6 +1756,8 @@ internal enum ErrorCode
17561756

17571757
WRN_DoesNotReturnMismatch = 8770,
17581758

1759+
ERR_StdInOptionProvidedButConsoleInputIsNotRedirected = 8782,
1760+
17591761
// Note: you will need to re-generate compiler code after adding warnings (eng\generate-compiler-code.cmd)
17601762
}
17611763
}

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

Lines changed: 72 additions & 68 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(isMethodBody: true);
2453+
blockBody = this.ParseMethodOrAccessorBodyBlock(isAccessorBody: false);
24542454
}
24552455

24562456
if (this.CurrentToken.Kind == SyntaxKind.EqualsGreaterThanToken)
@@ -2477,25 +2477,6 @@ private void ParseBlockAndExpressionBodiesWithSemicolon(
24772477
}
24782478
}
24792479

2480-
private void ParseBodyOrSemicolon(out BlockSyntax body, out SyntaxToken semicolon)
2481-
{
2482-
if (this.CurrentToken.Kind == SyntaxKind.OpenBraceToken)
2483-
{
2484-
body = this.ParseBlock(isMethodBody: true);
2485-
2486-
semicolon = null;
2487-
if (this.CurrentToken.Kind == SyntaxKind.SemicolonToken)
2488-
{
2489-
semicolon = this.EatTokenWithPrejudice(ErrorCode.ERR_UnexpectedSemicolon);
2490-
}
2491-
}
2492-
else
2493-
{
2494-
semicolon = this.EatToken(SyntaxKind.SemicolonToken);
2495-
body = null;
2496-
}
2497-
}
2498-
24992480
private bool IsEndOfTypeParameterList()
25002481
{
25012482
if (this.CurrentToken.Kind == SyntaxKind.OpenParenToken)
@@ -3305,7 +3286,7 @@ private AccessorDeclarationSyntax ParseAccessorDeclaration(bool isEvent)
33053286
{
33063287
if (!IsTerminator())
33073288
{
3308-
blockBody = this.ParseBlock(isMethodBody: true, isAccessorBody: true);
3289+
blockBody = this.ParseMethodOrAccessorBodyBlock(isAccessorBody: true);
33093290
}
33103291
else
33113292
{
@@ -6421,8 +6402,10 @@ private StatementSyntax ParseStatementNoDeclaration(bool allowAnyExpression)
64216402
case SyntaxKind.GotoKeyword:
64226403
return this.ParseGotoStatement();
64236404
case SyntaxKind.IfKeyword:
6424-
case SyntaxKind.ElseKeyword: // Including 'else' keyword to handle 'else without if' error cases
64256405
return this.ParseIfStatement();
6406+
case SyntaxKind.ElseKeyword:
6407+
// Including 'else' keyword to handle 'else without if' error cases
6408+
return this.ParseMisplacedElse();
64266409
case SyntaxKind.LockKeyword:
64276410
return this.ParseLockStatement();
64286411
case SyntaxKind.ReturnKeyword:
@@ -6941,54 +6924,66 @@ private bool IsPossibleNewExpression()
69416924
return null;
69426925
}
69436926

6944-
// If "isMethodBody" is true, then this is the immediate body of a method/accessor.
6945-
// In this case, we create a many-child list if the body is not a small single statement.
6946-
// This then allows a "with many weak children" red node when the red node is created.
6947-
// If "isAccessorBody" is true, then we produce a special diagnostic if the open brace is
6948-
// missing. Also, "isMethodBody" must be true.
6949-
private BlockSyntax ParseBlock(bool isMethodBody = false, bool isAccessorBody = false)
6927+
/// <summary>
6928+
/// Used to parse the block-body for a method or accessor. For blocks that appear *inside*
6929+
/// method bodies, call <see cref="ParseBlock"/>.
6930+
/// </summary>
6931+
/// <param name="isAccessorBody">If is true, then we produce a special diagnostic if the
6932+
/// open brace is missing.</param>
6933+
private BlockSyntax ParseMethodOrAccessorBodyBlock(bool isAccessorBody)
69506934
{
6951-
// Check again for incremental re-use, since ParseBlock is called from a bunch of places
6952-
// other than ParseStatementCore()
6935+
// Check again for incremental re-use. This way if a method signature is edited we can
6936+
// still quickly re-sync on the body.
69536937
if (this.IsIncrementalAndFactoryContextMatches && this.CurrentNodeKind == SyntaxKind.Block)
6954-
{
69556938
return (BlockSyntax)this.EatNode();
6956-
}
69576939

69586940
// There's a special error code for a missing token after an accessor keyword
6959-
var openBrace = isAccessorBody && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken
6941+
CSharpSyntaxNode openBrace = isAccessorBody && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken
69606942
? this.AddError(
69616943
SyntaxFactory.MissingToken(SyntaxKind.OpenBraceToken),
69626944
IsFeatureEnabled(MessageID.IDS_FeatureExpressionBodiedAccessor)
6963-
? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
6964-
: ErrorCode.ERR_SemiOrLBraceExpected)
6945+
? ErrorCode.ERR_SemiOrLBraceOrArrowExpected
6946+
: ErrorCode.ERR_SemiOrLBraceExpected)
69656947
: this.EatToken(SyntaxKind.OpenBraceToken);
69666948

69676949
var statements = _pool.Allocate<StatementSyntax>();
6968-
try
6969-
{
6970-
CSharpSyntaxNode tmp = openBrace;
6971-
this.ParseStatements(ref tmp, statements, stopOnSwitchSections: false);
6972-
openBrace = (SyntaxToken)tmp;
6973-
var closeBrace = this.EatToken(SyntaxKind.CloseBraceToken);
6950+
this.ParseStatements(ref openBrace, statements, stopOnSwitchSections: false);
69746951

6975-
SyntaxList<StatementSyntax> statementList;
6976-
if (isMethodBody && IsLargeEnoughNonEmptyStatementList(statements))
6977-
{
6978-
// Force creation a many-children list, even if only 1, 2, or 3 elements in the statement list.
6979-
statementList = new SyntaxList<StatementSyntax>(SyntaxList.List(((SyntaxListBuilder)statements).ToArray()));
6980-
}
6981-
else
6982-
{
6983-
statementList = statements;
6984-
}
6952+
var block = _syntaxFactory.Block(
6953+
(SyntaxToken)openBrace,
6954+
// Force creation a many-children list, even if only 1, 2, or 3 elements in the statement list.
6955+
IsLargeEnoughNonEmptyStatementList(statements)
6956+
? new SyntaxList<StatementSyntax>(SyntaxList.List(((SyntaxListBuilder)statements).ToArray()))
6957+
: statements,
6958+
this.EatToken(SyntaxKind.CloseBraceToken));
69856959

6986-
return _syntaxFactory.Block(openBrace, statementList, closeBrace);
6987-
}
6988-
finally
6989-
{
6990-
_pool.Free(statements);
6991-
}
6960+
_pool.Free(statements);
6961+
return block;
6962+
}
6963+
6964+
/// <summary>
6965+
/// Used to parse normal blocks that appear inside method bodies. For the top level block
6966+
/// of a method/accessor use <see cref="ParseMethodOrAccessorBodyBlock"/>.
6967+
/// </summary>
6968+
private BlockSyntax ParseBlock()
6969+
{
6970+
// Check again for incremental re-use, since ParseBlock is called from a bunch of places
6971+
// other than ParseStatementCore()
6972+
if (this.IsIncrementalAndFactoryContextMatches && this.CurrentNodeKind == SyntaxKind.Block)
6973+
return (BlockSyntax)this.EatNode();
6974+
6975+
CSharpSyntaxNode openBrace = this.EatToken(SyntaxKind.OpenBraceToken);
6976+
6977+
var statements = _pool.Allocate<StatementSyntax>();
6978+
this.ParseStatements(ref openBrace, statements, stopOnSwitchSections: false);
6979+
6980+
var block = _syntaxFactory.Block(
6981+
(SyntaxToken)openBrace,
6982+
statements,
6983+
this.EatToken(SyntaxKind.CloseBraceToken));
6984+
6985+
_pool.Free(statements);
6986+
return block;
69926987
}
69936988

69946989
// Is this statement list non-empty, and large enough to make using weak children beneficial?
@@ -7686,19 +7681,28 @@ private GotoStatementSyntax ParseGotoStatement()
76867681

76877682
private IfStatementSyntax ParseIfStatement()
76887683
{
7689-
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.IfKeyword || this.CurrentToken.Kind == SyntaxKind.ElseKeyword);
7684+
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.IfKeyword);
76907685

7691-
bool firstTokenIsElse = this.CurrentToken.Kind == SyntaxKind.ElseKeyword;
7692-
var @if = firstTokenIsElse
7693-
? this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement)
7694-
: this.EatToken(SyntaxKind.IfKeyword);
7695-
var openParen = this.EatToken(SyntaxKind.OpenParenToken);
7696-
var condition = this.ParseExpressionCore();
7697-
var closeParen = this.EatToken(SyntaxKind.CloseParenToken);
7698-
var statement = firstTokenIsElse ? this.ParseExpressionStatement() : this.ParseEmbeddedStatement();
7699-
var elseClause = this.ParseElseClauseOpt();
7686+
return _syntaxFactory.IfStatement(
7687+
this.EatToken(SyntaxKind.IfKeyword),
7688+
this.EatToken(SyntaxKind.OpenParenToken),
7689+
this.ParseExpressionCore(),
7690+
this.EatToken(SyntaxKind.CloseParenToken),
7691+
this.ParseEmbeddedStatement(),
7692+
this.ParseElseClauseOpt());
7693+
}
7694+
7695+
private IfStatementSyntax ParseMisplacedElse()
7696+
{
7697+
Debug.Assert(this.CurrentToken.Kind == SyntaxKind.ElseKeyword);
77007698

7701-
return _syntaxFactory.IfStatement(@if, openParen, condition, closeParen, statement, elseClause);
7699+
return _syntaxFactory.IfStatement(
7700+
this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement),
7701+
this.EatToken(SyntaxKind.OpenParenToken),
7702+
this.ParseExpressionCore(),
7703+
this.EatToken(SyntaxKind.CloseParenToken),
7704+
this.ParseExpressionStatement(),
7705+
this.ParseElseClauseOpt());
77027706
}
77037707

77047708
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
@@ -432,6 +432,11 @@
432432
<target state="translated">Statický člen {0} se nedá označit modifikátorem readonly.</target>
433433
<note />
434434
</trans-unit>
435+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
436+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
437+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
438+
<note />
439+
</trans-unit>
435440
<trans-unit id="ERR_SwitchArmSubsumed">
436441
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
437442
<target state="translated">Tento vzor už zpracovala předchozí větev výrazu switch.</target>
@@ -9845,4 +9850,4 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference
98459850
</trans-unit>
98469851
</body>
98479852
</file>
9848-
</xliff>
9853+
</xliff>

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@
432432
<target state="translated">Der statische Member "{0}" kann nicht als "readonly" markiert werden.</target>
433433
<note />
434434
</trans-unit>
435+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
436+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
437+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
438+
<note />
439+
</trans-unit>
435440
<trans-unit id="ERR_SwitchArmSubsumed">
436441
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
437442
<target state="translated">Das Muster wurde bereits durch einen vorherigen Zweig des switch-Ausdrucks verarbeitet.</target>
@@ -9845,4 +9850,4 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett
98459850
</trans-unit>
98469851
</body>
98479852
</file>
9848-
</xliff>
9853+
</xliff>

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@
432432
<target state="translated">El miembro estático "{0}" no se puede marcar como "readonly".</target>
433433
<note />
434434
</trans-unit>
435+
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
436+
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
437+
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
438+
<note />
439+
</trans-unit>
435440
<trans-unit id="ERR_SwitchArmSubsumed">
436441
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
437442
<target state="translated">El patrón ya se ha controlado con una parte anterior de la expresión switch.</target>
@@ -9845,4 +9850,4 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe
98459850
</trans-unit>
98469851
</body>
98479852
</file>
9848-
</xliff>
9853+
</xliff>

0 commit comments

Comments
 (0)