From e4ace12722b6cc41a943d15185e059c67b8dc617 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 May 2024 16:46:30 -0700 Subject: [PATCH 1/2] Remove VersionStamp serialization --- .../Workspace/Solution/VersionStamp.cs | 16 -------- src/Workspaces/CoreTest/SerializationTests.cs | 37 ------------------- 2 files changed, 53 deletions(-) delete mode 100644 src/Workspaces/CoreTest/SerializationTests.cs diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs b/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs index f0a4fc6bf828a..43b9771806e30 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs @@ -187,22 +187,6 @@ internal static bool CanReusePersistedVersion(VersionStamp baseVersion, VersionS return baseVersion._utcLastModified == persistedVersion._utcLastModified; } - internal void WriteTo(ObjectWriter writer) - { - writer.WriteInt64(_utcLastModified.ToBinary()); - writer.WriteInt32(_localIncrement); - writer.WriteInt32(_globalIncrement); - } - - internal static VersionStamp ReadFrom(ObjectReader reader) - { - var raw = reader.ReadInt64(); - var localIncrement = reader.ReadInt32(); - var globalIncrement = reader.ReadInt32(); - - return new VersionStamp(DateTime.FromBinary(raw), localIncrement, globalIncrement); - } - private static int GetGlobalVersion(VersionStamp version) { // global increment < 0 means it is a global version which has its global increment in local increment diff --git a/src/Workspaces/CoreTest/SerializationTests.cs b/src/Workspaces/CoreTest/SerializationTests.cs deleted file mode 100644 index ee8e276515d90..0000000000000 --- a/src/Workspaces/CoreTest/SerializationTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// 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.Test.Utilities; -using Roslyn.Test.Utilities; -using Roslyn.Utilities; -using Xunit; - -namespace Microsoft.CodeAnalysis.UnitTests -{ - [UseExportProvider] - public partial class SerializationTests : TestBase - { - [Fact] - public void VersionStamp_RoundTripText() - { - var versionStamp = VersionStamp.Create(); - - using var writerStream = new MemoryStream(); - - using (var writer = new ObjectWriter(writerStream, leaveOpen: true)) - { - versionStamp.WriteTo(writer); - } - - using var readerStream = new MemoryStream(writerStream.ToArray()); - using var reader = ObjectReader.TryGetReader(readerStream); - var deserializedVersionStamp = VersionStamp.ReadFrom(reader); - - Assert.Equal(versionStamp, deserializedVersionStamp); - } - } -} From 9cacb8319a4e0e285e9587b4910b50f313649b9e Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 6 May 2024 16:51:38 -0700 Subject: [PATCH 2/2] remove more! --- .../Workspace/Solution/VersionStamp.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs b/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs index 43b9771806e30..34872c1b0c2d7 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/VersionStamp.cs @@ -168,25 +168,6 @@ public bool Equals(VersionStamp version) public static bool operator !=(VersionStamp left, VersionStamp right) => !left.Equals(right); - /// - /// Check whether given persisted version is re-usable. Used by VS for Mac - /// - internal static bool CanReusePersistedVersion(VersionStamp baseVersion, VersionStamp persistedVersion) - { - if (baseVersion == persistedVersion) - { - return true; - } - - // there was a collision, we can't use these - if (baseVersion._localIncrement != 0 || persistedVersion._localIncrement != 0) - { - return false; - } - - return baseVersion._utcLastModified == persistedVersion._utcLastModified; - } - private static int GetGlobalVersion(VersionStamp version) { // global increment < 0 means it is a global version which has its global increment in local increment