fix: support Visual Studio 2026 package loading
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Prophet.CoopWithDsh
|
||||
{
|
||||
internal sealed class SnapshotPublisher : IDisposable
|
||||
{
|
||||
private static readonly DataContractJsonSerializer Serializer = new DataContractJsonSerializer(typeof(OpenFileSnapshot));
|
||||
private readonly object gate = new object();
|
||||
internal string InstanceId { get; } = Guid.NewGuid().ToString("N");
|
||||
internal string FilePath { get; }
|
||||
@@ -26,7 +27,11 @@ namespace Prophet.CoopWithDsh
|
||||
var directory = Path.GetDirectoryName(FilePath)!;
|
||||
Directory.CreateDirectory(directory);
|
||||
var temporary = FilePath + "." + Guid.NewGuid().ToString("N") + ".tmp";
|
||||
File.WriteAllText(temporary, JsonConvert.SerializeObject(snapshot) + Environment.NewLine, new UTF8Encoding(false));
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
Serializer.WriteObject(stream, snapshot);
|
||||
File.WriteAllText(temporary, Encoding.UTF8.GetString(stream.ToArray()) + Environment.NewLine, new UTF8Encoding(false));
|
||||
}
|
||||
try
|
||||
{
|
||||
if (File.Exists(FilePath)) File.Replace(temporary, FilePath, null);
|
||||
|
||||
Reference in New Issue
Block a user