Skip to content

Commit

Permalink
Updated odin serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
IntoTheDev committed Jul 18, 2022
1 parent ac3ed27 commit 7bc0b38
Show file tree
Hide file tree
Showing 219 changed files with 597 additions and 266 deletions.
2 changes: 1 addition & 1 deletion OdinSerializer/Config/AssemblyBuildInfo.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Config/GlobalSerializationConfig.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/DataReaderWriters.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract class BaseDataReaderWriter
/// The reader's or writer's serialization binder.
/// </value>
[Obsolete("Use the Binder member on the writer's SerializationContext/DeserializationContext instead.", error: false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public TwoWaySerializationBinder Binder
{
get
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/DataReaderWriters/Binary.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ public override bool EnterNode(out Type type)
}
else if (this.peekedBinaryEntryType == BinaryEntryType.NamedStartOfStructNode || this.peekedBinaryEntryType == BinaryEntryType.UnnamedStartOfStructNode)
{
this.MarkEntryContentConsumed();
type = this.ReadTypeEntry();
this.PushNode(this.peekedEntryName, -1, type);
this.MarkEntryContentConsumed();
return true;
}
else
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion OdinSerializer/Core/DataReaderWriters/IDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public interface IDataReader : IDisposable
/// The base stream of the reader.
/// </value>
[Obsolete("Data readers and writers don't necessarily have streams any longer, so this API has been made obsolete. Using this property may result in NotSupportedExceptions being thrown.", false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
Stream Stream { get; set; }

/// <summary>
/// Gets a value indicating whether the reader is in an array node.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion OdinSerializer/Core/DataReaderWriters/IDataReader.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions OdinSerializer/Core/DataReaderWriters/IDataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface IDataWriter : IDisposable
/// The base stream of the writer.
/// </value>
[Obsolete("Data readers and writers don't necessarily have streams any longer, so this API has been made obsolete. Using this property may result in NotSupportedExceptions being thrown.", false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
Stream Stream { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OdinSerializer/Core/DataReaderWriters/IDataWriter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/DataReaderWriters/Json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions OdinSerializer/Core/DataReaderWriters/Json/JsonConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ public static class JsonConfig
public const string EXTERNAL_GUID_REF_SIG = "$guidref";

/// <summary>
/// The beginning of the content of an external reference by string entry.
/// The beginning of the content of an external reference by string entry. This is an old entry using an invalid data format where the ref string is dumped inline without escaping.
/// </summary>
public const string EXTERNAL_STRING_REF_SIG = "$strref";
public const string EXTERNAL_STRING_REF_SIG_OLD = "$strref";

/// <summary>
/// The beginning of the content of an external reference by string entry. This is a new entry using the valid format where the ref string is written as an escaped string.
/// </summary>
public const string EXTERNAL_STRING_REF_SIG_FIXED = "$fstrref";
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions OdinSerializer/Core/DataReaderWriters/Json/JsonDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,13 @@ public override bool ReadExternalReference(out string id)
{
id = this.peekedEntryContent;

if (id.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG))
if (id.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG_OLD))
{
id = id.Substring(JsonConfig.EXTERNAL_STRING_REF_SIG.Length + 1);
id = id.Substring(JsonConfig.EXTERNAL_STRING_REF_SIG_OLD.Length + 1);
}
else if (id.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED))
{
id = id.Substring(JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED.Length + 2, id.Length - (JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED.Length + 3));
}

this.MarkEntryConsumed();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion OdinSerializer/Core/DataReaderWriters/Json/JsonDataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,12 @@ public override void WriteExternalReference(string name, string id)
throw new ArgumentNullException("id");
}

this.WriteEntry(name, JsonConfig.EXTERNAL_STRING_REF_SIG + ":" + id);
this.WriteEntry(name, JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED);
this.EnsureBufferSpace(id.Length + 3);
this.buffer[this.bufferIndex++] = (byte)':';
this.buffer[this.bufferIndex++] = (byte)'"';
this.Buffer_WriteString_WithEscape(id);
this.buffer[this.bufferIndex++] = (byte)'"';
}

/// <summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions OdinSerializer/Core/DataReaderWriters/Json/JsonTextReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,26 @@ private void ParseEntryFromBuffer(out string name, out string valueContent, out
return;
}

if (string.Equals(name, JsonConfig.EXTERNAL_STRING_REF_SIG, StringComparison.InvariantCulture))
if (string.Equals(name, JsonConfig.EXTERNAL_STRING_REF_SIG_OLD, StringComparison.InvariantCulture))
{
// It's an external guid reference without a name
// It's an external guid reference without a name, of the old broken kind
// The content is the whole buffer
name = null;
valueContent = new string(this.buffer, 0, this.bufferIndex + 1);
entry = EntryType.ExternalReferenceByString;
return;
}

if (string.Equals(name, JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED, StringComparison.InvariantCulture))
{
// It's an external guid reference without a name, of the new non-broken kind
// The content is the buffer, unquoted and unescaped
name = null;
valueContent = new string(this.buffer, 0, this.bufferIndex + 1);
entry = EntryType.ExternalReferenceByString;
return;
}

if (this.bufferIndex >= valueSeparatorIndex)
{
valueContent = new string(this.buffer, valueSeparatorIndex + 1, this.bufferIndex - valueSeparatorIndex);
Expand Down Expand Up @@ -531,7 +541,12 @@ private void ParseEntryFromBuffer(out string name, out string valueContent, out
entry = EntryType.ExternalReferenceByGuid;
return;
}
else if (valueContent.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG, StringComparison.InvariantCulture))
else if (valueContent.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG_OLD, StringComparison.InvariantCulture))
{
entry = EntryType.ExternalReferenceByString;
return;
}
else if (valueContent.StartsWith(JsonConfig.EXTERNAL_STRING_REF_SIG_FIXED, StringComparison.InvariantCulture))
{
entry = EntryType.ExternalReferenceByString;
return;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/FormatterLocators.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion OdinSerializer/Core/FormatterLocators/FormatterLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static FormatterLocator()
// Filter out various core .NET libraries and Unity engine assemblies
continue;
}
else if (ass.GetName().Name == FormatterEmitter.PRE_EMITTED_ASSEMBLY_NAME || ass.IsDefined(typeof(EmittedAssemblyAttribute), true))
else if (ass.GetName().Name == FormatterEmitter.PRE_EMITTED_ASSEMBLY_NAME || ass.SafeIsDefined(typeof(EmittedAssemblyAttribute), true))
{
// Only include pre-emitted formatters if we are on an AOT platform.
// Pre-emitted formatters will not work in newer .NET runtimes due to
Expand Down Expand Up @@ -205,6 +205,7 @@ static FormatterLocator()
/// This can be used to hook into and extend the serialization system's formatter resolution logic.
/// </summary>
[Obsolete("Use the new IFormatterLocator interface instead, and register your custom locator with the RegisterFormatterLocator assembly attribute.", true)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public static event Func<Type, IFormatter> FormatterResolve
{
add { throw new NotSupportedException(); }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/Formatters.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/Formatters/ArrayFormatter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/Formatters/ArrayListFormatter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/Formatters/BaseFormatter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion OdinSerializer/Core/Formatters/DateTimeFormatter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7bc0b38

Please sign in to comment.