/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/VisualStudio/CSharp/Test/ProjectSystemShim/TempPECompilerServiceTests.cs
49 строк
2 KB
Cyrus Najmabadi
Use file scoped namespaces. (#77854)
27 мар 2025, 09:55
Не верифицирован
27 мар 2025, 09:55
98d41b8
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System.IO; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.VisualStudio; using Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim; using Xunit; namespace Roslyn.VisualStudio.CSharp.UnitTests.ProjectSystemShim; public sealed class TempPECompilerServiceTests { [Fact] public void TempPECompilationWithInvalidReferenceDoesNotCrash() { var tempPEService = new TempPECompilerService(new TrivialMetadataService()); using var tempRoot = new TempRoot(); var directory = tempRoot.CreateDirectory(); // This should not crash. Visual inspection of the Dev12 codebase implied we might return // S_FALSE in this case, but it wasn't very clear. In any case, it's not expected to throw,m // so S_FALSE seems fine. var hr = tempPEService.CompileTempPE( pszOutputFileName: Path.Combine(directory.Path, "Output.dll"), sourceCount: 0, fileNames: [], fileContents: [], optionCount: 1, optionNames: ["r"], optionValues: [Path.Combine(directory.Path, "MissingReference.dll")]); Assert.Equal(VSConstants.S_FALSE, hr); } private sealed class TrivialMetadataService : IMetadataService { public PortableExecutableReference GetReference(string resolvedPath, MetadataReferenceProperties properties) { return MetadataReference.CreateFromFile(resolvedPath, properties); } } }