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

Add ability to compile code from stdin #41166

Merged
merged 10 commits into from Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions Compilers.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27102.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.UnitTests", "src\Compilers\Core\CodeAnalysisTest\Microsoft.CodeAnalysis.UnitTests.csproj", "{A4C99B85-765C-4C65-9C2A-BB609AAB09E6}"
EndProject
Expand Down Expand Up @@ -160,6 +160,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildBoss", "src\Tools\Buil
EndProject
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}"
EndProject
Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "vbi", "src\Interactive\vbi\vbi.vbproj", "{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
Expand Down Expand Up @@ -435,6 +437,10 @@ Global
{6D407402-CC4A-4125-9B00-C70562A636A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D407402-CC4A-4125-9B00-C70562A636A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D407402-CC4A-4125-9B00-C70562A636A5}.Release|Any CPU.Build.0 = Release|Any CPU
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -508,6 +514,7 @@ Global
{B446E771-AB52-41C9-ACFC-FDF8EACAF291} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{8A02AFAF-F622-4E3E-9E1A-8CFDACC7C7E1} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{6D407402-CC4A-4125-9B00-C70562A636A5} = {274B96B7-F815-47E3-9CA4-4024A57A478F}
{706CFC25-B6E0-4DAA-BCC4-F6FAAFEEDF87} = {3FF38FD4-DF16-44B0-924F-0D5AE155495B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6F599E08-A9EA-4FAA-897F-5D824B0210E6}
Expand Down
15 changes: 13 additions & 2 deletions src/Compilers/CSharp/Portable/CSharpResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Expand Up @@ -5081,6 +5081,9 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_SwitchCaseSubsumed" xml:space="preserve">
<value>The switch case has already been handled by a previous case.</value>
</data>
<data name="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected" xml:space="preserve">
<value>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</value>
</data>
<data name="ERR_SwitchArmSubsumed" xml:space="preserve">
<value>The pattern has already been handled by a previous arm of the switch expression.</value>
</data>
Expand Down Expand Up @@ -5990,4 +5993,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_ImplicitRangeIndexerWithName" xml:space="preserve">
<value>Invocation of implicit Range Indexer cannot name the argument.</value>
</data>
</root>
</root>
Expand Up @@ -224,6 +224,19 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
{
case "-": // csi -- script.csx
if (value != null) break;
if (arg == "-")
{
if (Console.IsInputRedirected)
{
sourceFiles.Add(new CommandLineSourceFile("-", isScript: true, isInputRedirected: true));
sourceFilesSpecified = true;
}
else
{
AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
}
continue;
}

// Indicates that the remaining arguments should not be treated as options.
optionsEnded = true;
Expand Down Expand Up @@ -1260,6 +1273,18 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
embeddedFiles.Add(ToCommandLineSourceFile(path));
}
continue;

case "-":
if (Console.IsInputRedirected)
{
sourceFiles.Add(new CommandLineSourceFile("-", isScript: false, isInputRedirected: true));
sourceFilesSpecified = true;
}
else
{
AddDiagnostic(diagnostics, ErrorCode.ERR_StdInOptionProvidedButConsoleInputIsNotRedirected);
}
continue;
}
}

Expand Down
Expand Up @@ -109,7 +109,7 @@ protected CSharpCompiler(CSharpCommandLineParser parser, string responseFile, st
{
var normalizedFilePath = normalizedFilePaths[i];
Debug.Assert(normalizedFilePath != null);
Debug.Assert(PathUtilities.IsAbsolute(normalizedFilePath));
Debug.Assert(sourceFiles[i].IsInputRedirected || PathUtilities.IsAbsolute(normalizedFilePath));

if (!uniqueFilePaths.Add(normalizedFilePath))
{
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Expand Up @@ -1756,6 +1756,8 @@ internal enum ErrorCode

WRN_DoesNotReturnMismatch = 8770,

ERR_StdInOptionProvidedButConsoleInputIsNotRedirected = 8782,

// Note: you will need to re-generate compiler code after adding warnings (eng\generate-compiler-code.cmd)
}
}
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Statický člen {0} se nedá označit modifikátorem readonly.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Tento vzor už zpracovala předchozí větev výrazu switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Der statische Member "{0}" kann nicht als "readonly" markiert werden.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Das Muster wurde bereits durch einen vorherigen Zweig des switch-Ausdrucks verarbeitet.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">El miembro estático "{0}" no se puede marcar como "readonly".</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">El patrón ya se ha controlado con una parte anterior de la expresión switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Le membre statique '{0}' ne peut pas être marqué 'readonly'.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Le modèle a déjà été traité par un bras précédent de l'expression switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Pour supprimer l'avertissement, vous pouvez utiliser la commande /reference (dé
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Il membro statico '{0}' non può essere contrassegnato come 'readonly'.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Il criterio è già stato gestito da un elemento precedente dell'espressione switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Per rimuovere l'avviso, è invece possibile usare /reference (impostare la propr
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">静的メンバー '{0}' を 'readonly' とマークすることはできません。</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">このパターンは、switch 式の前の arm で既に処理されています。</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">정적 멤버 '{0}'을(를) 'readonly'로 표시할 수 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">패턴이 switch 식의 이전 arm에 의해 이미 처리되었습니다.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Składowa statyczna „{0}” nie może być oznaczona jako „readonly”.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Wzorzec został już obsłużony przez poprzednie rozgałęzienie wyrażenia switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Aby usunąć ostrzeżenie, możesz zamiast tego użyć opcji /reference (ustaw w
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">O membro estático '{0}' não pode ser marcado como 'readonly'.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">O padrão já foi manipulado por um braço anterior da expressão switch.</target>
Expand Down Expand Up @@ -9843,4 +9848,4 @@ Para incorporar informações de tipo de interoperabilidade para os dois assembl
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Статический член "{0}" не может быть помечен как readonly.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Шаблон уже был обработан предыдущей стороной выражения switch.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
</trans-unit>
</body>
</file>
</xliff>
</xliff>
7 changes: 6 additions & 1 deletion src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
Expand Up @@ -432,6 +432,11 @@
<target state="translated">'{0}' statik üyesi 'readonly' olarak işaretlenemez.</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">Desen zaten switch deyiminin önceki bir kolu tarafından işlendi.</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ Uyarıyı kaldırmak için, /reference kullanabilirsiniz (Birlikte Çalışma T
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Expand Up @@ -432,6 +432,11 @@
<target state="translated">静态成员 "{0}" 不能标记为 "readonly"。</target>
<note />
</trans-unit>
<trans-unit id="ERR_StdInOptionProvidedButConsoleInputIsNotRedirected">
<source>stdin argument '-' is specified, but input has not been redirected from the standard input stream.</source>
<target state="new">stdin argument '-' is specified, but input has not been redirected from the standard input stream.</target>
<note />
</trans-unit>
<trans-unit id="ERR_SwitchArmSubsumed">
<source>The pattern has already been handled by a previous arm of the switch expression.</source>
<target state="translated">该模式已由 switch 表达式的前一个 arm 处理。</target>
Expand Down Expand Up @@ -9845,4 +9850,4 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
</trans-unit>
</body>
</file>
</xliff>
</xliff>