未验证 提交 a171bdc9 编写于 作者: J Joey Robichaud 提交者: GitHub

Merge pull request #42928 from JoeRobich/workaround-platformexception

Use the Trivial temporary storage service on non-windows platforms
......@@ -19,7 +19,7 @@
namespace Microsoft.CodeAnalysis.Host
{
[ExportWorkspaceServiceFactory(typeof(ITemporaryStorageService), ServiceLayer.Host), Shared]
[ExportWorkspaceServiceFactory(typeof(ITemporaryStorageService), ServiceLayer.Default), Shared]
internal partial class TemporaryStorageServiceFactory : IWorkspaceServiceFactory
{
[ImportingConstructor]
......@@ -31,7 +31,13 @@ public TemporaryStorageServiceFactory()
public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices)
{
var textFactory = workspaceServices.GetService<ITextFactoryService>();
return new TemporaryStorageService(textFactory);
// MemoryMapped files which are used by the TemporaryStorageService are present in .NET Framework (including Mono)
// and .NET Core Windows. For non-Windows .NET Core scenarios, we can return the TrivialTemporaryStorageService
// until https://github.com/dotnet/roslyn/issues/42178 is fixed.
return PlatformInformation.IsWindows || PlatformInformation.IsRunningOnMono
? (ITemporaryStorageService)new TemporaryStorageService(textFactory)
: TrivialTemporaryStorageService.Instance;
}
/// <summary>
......
......@@ -3,22 +3,19 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Composition;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis
{
[ExportWorkspaceService(typeof(ITemporaryStorageService)), Shared]
internal sealed class TrivialTemporaryStorageService : ITemporaryStorageService
{
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public TrivialTemporaryStorageService()
public static readonly TrivialTemporaryStorageService Instance = new TrivialTemporaryStorageService();
private TrivialTemporaryStorageService()
{
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册