|
| 1 | +' Licensed to the .NET Foundation under one or more agreements. |
| 2 | +' The .NET Foundation licenses this file to you under the MIT license. |
| 3 | +' See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +Imports System.IO |
| 6 | +Imports System.Threading |
| 7 | +Imports Microsoft.CodeAnalysis.Serialization |
| 8 | +Imports Microsoft.CodeAnalysis.Test.Utilities |
| 9 | +Imports Roslyn.Test.Utilities |
| 10 | +Imports Roslyn.Utilities |
| 11 | +Imports Xunit |
| 12 | + |
| 13 | +Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Serialization |
| 14 | + <UseExportProvider> |
| 15 | + Public NotInheritable Class OptionsSerializationTests |
| 16 | + <Fact, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2325692")> |
| 17 | + Public Sub TestNullGlobalImport() |
| 18 | + Dim options = New VisualBasicCompilationOptions( |
| 19 | + OutputKind.ConsoleApplication, |
| 20 | + "module", |
| 21 | + globalImports:={Nothing}) |
| 22 | + |
| 23 | + Using workspace = New AdhocWorkspace() |
| 24 | + Dim service = workspace.Services.GetLanguageServices(LanguageNames.VisualBasic).GetService(Of IOptionsSerializationService)() |
| 25 | + |
| 26 | + Using stream = New MemoryStream() |
| 27 | + Dim writer = New ObjectWriter(stream, leaveOpen:=True) |
| 28 | + service.WriteTo(options, writer, CancellationToken.None) |
| 29 | + stream.Position = 0 |
| 30 | + |
| 31 | + Dim reader = ObjectReader.TryGetReader(stream, leaveOpen:=True) |
| 32 | + Dim serializedOptions = DirectCast( |
| 33 | + service.ReadCompilationOptionsFrom(reader, CancellationToken.None), |
| 34 | + VisualBasicCompilationOptions) |
| 35 | + |
| 36 | + Assert.Empty(serializedOptions.GlobalImports) |
| 37 | + End Using |
| 38 | + End Using |
| 39 | + End Sub |
| 40 | + End Class |
| 41 | +End Namespace |
0 commit comments