Skip to content

Commit 5d660bd

Browse files
committed
Remove debugging statements from NeoBinarySerializer
1 parent d9d1b5a commit 5d660bd

File tree

1 file changed

+3
-105
lines changed

1 file changed

+3
-105
lines changed

CoreRemoting/Serialization/NeoBinary/NeoBinarySerializer.cs

Lines changed: 3 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private void ReadHeader(BinaryReader reader)
268268
// Read CoreRemoting version for compatibility checking
269269
var remoteVersion = reader.ReadString();
270270
var localVersion = COREMOTING_VERSION;
271-
var flags = reader.ReadUInt16();
271+
reader.ReadUInt16(); // Read flags
272272

273273
// Enhanced version negotiation
274274
var versionMismatch = !string.IsNullOrEmpty(remoteVersion) && remoteVersion != localVersion;
@@ -283,28 +283,8 @@ private void ReadHeader(BinaryReader reader)
283283
throw new InvalidOperationException(
284284
$"Major version mismatch detected. Local: {localVersion}, Remote: {remoteVersion}. " +
285285
$"This indicates incompatible CoreRemoting versions.");
286-
287-
// Minor version differences are warnings
288-
if (localVer.Minor != remoteVer.Minor)
289-
{
290-
Console.WriteLine($"WARNING: Minor CoreRemoting version difference detected:");
291-
Console.WriteLine($" Local version: {localVersion}");
292-
Console.WriteLine($" Remote version: {remoteVersion}");
293-
Console.WriteLine($" This should be compatible but may cause minor issues.");
294-
}
295-
}
296-
else
297-
{
298-
// Fallback for unparseable version strings
299-
Console.WriteLine($"WARNING: CoreRemoting version mismatch detected (could not parse versions):");
300-
Console.WriteLine($" Local version: {localVersion}");
301-
Console.WriteLine($" Remote version: {remoteVersion}");
302-
Console.WriteLine($" This may cause serialization compatibility issues.");
303286
}
304287
}
305-
306-
// Validate flag compatibility
307-
ValidateFlagCompatibility(flags, remoteVersion, localVersion);
308288
}
309289

310290
private void SerializeObject(object obj, BinaryWriter writer, HashSet<object> serializedObjects,
@@ -661,12 +641,6 @@ private object DeserializeObject(BinaryReader reader, Dictionary<int, object> de
661641

662642
private void WriteTypeInfo(BinaryWriter writer, Type type)
663643
{
664-
#if DEBUG
665-
var streamPos = writer.BaseStream.CanSeek ? writer.BaseStream.Position : -1;
666-
Console.WriteLine(
667-
$"DEBUG: WriteTypeInfo called for type: {type?.FullName ?? "null"} at position {streamPos}");
668-
#endif
669-
670644
if (type == null)
671645
{
672646
// Special handling for null type to keep stream alignment consistent
@@ -770,11 +744,6 @@ private void WriteTypeInfo(BinaryWriter writer, Type type)
770744
typeName = _serializerCache.GetOrCreatePooledString(typeName);
771745
writer.Write(typeName);
772746

773-
#if DEBUG
774-
var afterTypeNamePos = writer.BaseStream.CanSeek ? writer.BaseStream.Position : -1;
775-
Console.WriteLine($"DEBUG: WriteTypeInfo wrote typeName: '{typeName}' at position {afterTypeNamePos}");
776-
#endif
777-
778747
var assemblyNameString = assemblyName.Name ?? string.Empty;
779748
assemblyNameString = _serializerCache.GetOrCreatePooledString(assemblyNameString);
780749
writer.Write(assemblyNameString);
@@ -1220,10 +1189,6 @@ private bool IsSimpleType(Type type)
12201189
// Defensive check: ensure class types are not accidentally marked as simple
12211190
if (isSimple && type.IsClass && !type.IsEnum && type != typeof(string))
12221191
{
1223-
#if DEBUG
1224-
Console.WriteLine(
1225-
$"DEBUG: Class type {type.FullName} was incorrectly identified as simple. IsPrimitive={type.IsPrimitive}");
1226-
#endif
12271192
return false;
12281193
}
12291194

@@ -1508,6 +1473,7 @@ private object CreateInstanceWithoutConstructor(Type type)
15081473
}
15091474

15101475
if (canCreate)
1476+
{
15111477
try
15121478
{
15131479
return ctor.Invoke(args);
@@ -1516,6 +1482,7 @@ private object CreateInstanceWithoutConstructor(Type type)
15161482
{
15171483
// Try next constructor
15181484
}
1485+
}
15191486
}
15201487
}
15211488

@@ -1613,54 +1580,6 @@ private void ValidateStreamState(BinaryReader reader, string context)
16131580
$"Stream corruption detected in {context}: Attempting to read at end of stream (position: {position}, length: {length})");
16141581
}
16151582

1616-
1617-
/// <summary>
1618-
/// Validates flag compatibility between serializer configurations.
1619-
/// </summary>
1620-
/// <param name="remoteFlags">Flags from remote endpoint</param>
1621-
/// <param name="remoteVersion">Remote version string</param>
1622-
/// <param name="localVersion">Local version string</param>
1623-
private void ValidateFlagCompatibility(ushort remoteFlags, string remoteVersion, string localVersion)
1624-
{
1625-
const ushort VERSION_FLAG = 0x01; // Include assembly versions
1626-
const ushort TYPEREF_FLAG = 0x02; // Use type references
1627-
1628-
var localFlags = 0;
1629-
if (Config.IncludeAssemblyVersions) localFlags |= VERSION_FLAG;
1630-
if (Config.UseTypeReferences) localFlags |= TYPEREF_FLAG;
1631-
1632-
// Check for incompatible flag combinations
1633-
var incompatibleFlags = remoteFlags ^ localFlags;
1634-
1635-
if ((incompatibleFlags & VERSION_FLAG) != 0)
1636-
{
1637-
var remoteHasVersion = (remoteFlags & VERSION_FLAG) != 0;
1638-
var localHasVersion = (localFlags & VERSION_FLAG) != 0;
1639-
1640-
if (remoteHasVersion != localHasVersion)
1641-
{
1642-
Console.WriteLine($"WARNING: Assembly version inclusion mismatch:");
1643-
Console.WriteLine($" Local includes assembly versions: {localHasVersion}");
1644-
Console.WriteLine($" Remote includes assembly versions: {remoteHasVersion}");
1645-
Console.WriteLine($" This may cause type resolution issues.");
1646-
}
1647-
}
1648-
1649-
if ((incompatibleFlags & TYPEREF_FLAG) != 0)
1650-
{
1651-
var remoteHasTypeRef = (remoteFlags & TYPEREF_FLAG) != 0;
1652-
var localHasTypeRef = (localFlags & TYPEREF_FLAG) != 0;
1653-
1654-
if (remoteHasTypeRef != localHasTypeRef)
1655-
{
1656-
Console.WriteLine($"WARNING: Type reference usage mismatch:");
1657-
Console.WriteLine($" Local uses type references: {localHasTypeRef}");
1658-
Console.WriteLine($" Remote uses type references: {remoteHasTypeRef}");
1659-
Console.WriteLine($" This may affect serialization performance and compatibility.");
1660-
}
1661-
}
1662-
}
1663-
16641583
/// <summary>
16651584
/// Validates if a byte is a valid object marker in NeoBinary protocol.
16661585
/// </summary>
@@ -1765,27 +1684,6 @@ private static string FormatHexDump(byte[] bytes, long startOffset)
17651684
return sb.ToString();
17661685
}
17671686

1768-
/// <summary>
1769-
/// Analyzes the current serialization stream for debugging and corruption detection.
1770-
/// </summary>
1771-
/// <param name="stream">Stream to analyze</param>
1772-
/// <returns>Detailed analysis report</returns>
1773-
public static StreamAnalysisReport AnalyzeStream(Stream stream)
1774-
{
1775-
return NeoBinaryStreamAnalyzer.AnalyzeStream(stream);
1776-
}
1777-
1778-
/// <summary>
1779-
/// Creates a hex dump of the stream for debugging purposes.
1780-
/// </summary>
1781-
/// <param name="stream">Stream to dump</param>
1782-
/// <param name="maxBytes">Maximum bytes to include in dump</param>
1783-
/// <returns>Hex dump string</returns>
1784-
public static string CreateHexDump(Stream stream, int maxBytes = 1024)
1785-
{
1786-
return NeoBinaryStreamAnalyzer.CreateHexDump(stream, maxBytes);
1787-
}
1788-
17891687
/// <summary>
17901688
/// Disposes the serializer and cleans up caches.
17911689
/// </summary>

0 commit comments

Comments
 (0)