diff --git a/docs/compilers/Visual Basic/Compiler Breaking Changes.md b/docs/compilers/Visual Basic/Compiler Breaking Changes.md new file mode 100644 index 0000000000000000000000000000000000000000..eac6344e907d770b63b7362e75f1e5757c98bf64 --- /dev/null +++ b/docs/compilers/Visual Basic/Compiler Breaking Changes.md @@ -0,0 +1,8 @@ +**This document lists known breaking changes in Roslyn (VS2015+) from the native VB compiler (VS2013 and previous).** + +*Breaks are formatted with a monotonically increasing numbered list to allow them to referenced via shorthand (i.e., "known break #1"). +Each entry should include a short description of the break, followed by either a link to the issue describing the full details of the break or the full details of the break inline.* + +1. When specifying the output extension as one of the known output types (example /out:foo.dll), but specifying a different target type + (example /t:exe) the compiler will now keep the specified extension and won't add the target extension (example foo.dll.exe). See + [#13681](https://github.com/dotnet/roslyn/issues/13681) for examples and details. diff --git a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb index 9379fcc22985db0af00c4bddd66d5c2cee7a15c3..612d85c0914adfd6ec4c92197b03d544c57141dc 100644 --- a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb +++ b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb @@ -2216,10 +2216,12 @@ lVbRuntimePlus: outputFileName = outputFileName & ".netmodule" End If Else - Dim defaultExtension As String = kind.GetDefaultExtension() - If Not String.Equals(ext, defaultExtension, StringComparison.OrdinalIgnoreCase) Then + If Not ext.Equals(".exe", StringComparison.OrdinalIgnoreCase) And + Not ext.Equals(".dll", StringComparison.OrdinalIgnoreCase) And + Not ext.Equals(".netmodule", StringComparison.OrdinalIgnoreCase) And + Not ext.Equals(".winmdobj", StringComparison.OrdinalIgnoreCase) Then simpleName = outputFileName - outputFileName = outputFileName & defaultExtension + outputFileName = outputFileName & kind.GetDefaultExtension() End If If simpleName Is Nothing Then diff --git a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb index 1848e5946992880fb6892ddd4742cb360ac78791..8ba44c0aefa7e392e9ae5984d3a4a8f6f9f07e6e 100644 --- a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb +++ b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb @@ -7944,6 +7944,53 @@ End Class Next End Sub + + + 'Output with known but different extension + 'Output with known but different extension (different casing) + 'Output with known but different extension + 'Output with known but different extension (different casing) + 'Output with known but different extension + 'Output with known but different extension + 'Output with known but different extension + 'Output with unknown extension (.txt) + 'Output with unknown extension (.md) + 'Output without extension + 'Output without extension + 'Output without extension + 'Output without extension + 'Output with correct extension (.exe) + 'Output with correct extension (.dll) + 'Output with correct extension (.netmodule) + 'Output with correct extension (.netmodule) (different casing) + 'Output with correct extension (.winmdobj) + Public Sub OutputingFilesWithDifferentExtensions(targetArg As String, outArg As String, expectedFile As String, unexpectedFile As String) + Dim source = + + + + + + + Dim fileName = "a.vb" + Dim dir = Temp.CreateDirectory() + Dim sourceFile = dir.CreateFile(fileName) + sourceFile.WriteAllText(source.Value) + + Dim output As New StringWriter() + + Assert.Equal(0, New MockVisualBasicCompiler(Nothing, dir.Path, {fileName, targetArg, outArg}).Run(output, Nothing)) + Assert.True(File.Exists(Path.Combine(dir.Path, expectedFile)), "Expected to find: " & expectedFile) + Assert.False(File.Exists(Path.Combine(dir.Path, unexpectedFile)), "Didn't expect to find: " & unexpectedFile) + + CleanupAllGeneratedFiles(sourceFile.Path) + End Sub + End Class