From f1a2a4d9db30344ad60c741a2b33c60d19b04495 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 13 Mar 2024 09:48:58 +0100 Subject: [PATCH] Protocol: make some members non-public. --- docs/protocol.md | 26 +++++++++---------- src/Tmds.DBus.Protocol/MessageWriter.Array.cs | 4 +-- src/Tmds.DBus.Protocol/Reader.Array.cs | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/protocol.md b/docs/protocol.md index 939e359c..1a0b7074 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -210,19 +210,6 @@ Note: this example shows how to writing an array of strings. There is a `WriteAr ### Reading a dictionary -```cs -ArrayStart arrayStart = writer.WriteDictionaryStart(); -foreach (var item in value) -{ - writer.WriteDictionaryEntryStart(); - writer.Write... // write the key - writer.Write... // write the value -} -writer.WriteDictionaryEnd(arrayStart); -``` - -### Reading a dictionary - ```cs Dictionary dictionary = new(); ArrayEnd dictEnd = reader.ReadDictionaryStart(); @@ -234,6 +221,19 @@ while (reader.HasNext(dictEnd)) } ``` +### Writing a dictionary + +```cs +ArrayStart arrayStart = writer.WriteDictionaryStart(); +foreach (var item in value) +{ + writer.WriteDictionaryEntryStart(); + writer.Write... // write the key + writer.Write... // write the value +} +writer.WriteDictionaryEnd(arrayStart); +``` + ### Reading a struct To read a struct call `AlignStruct` and then read the struct fields. diff --git a/src/Tmds.DBus.Protocol/MessageWriter.Array.cs b/src/Tmds.DBus.Protocol/MessageWriter.Array.cs index 71fb0f97..3739a257 100644 --- a/src/Tmds.DBus.Protocol/MessageWriter.Array.cs +++ b/src/Tmds.DBus.Protocol/MessageWriter.Array.cs @@ -132,9 +132,7 @@ public void WriteArray(IEnumerable value) WriteArrayEnd(arrayStart); } - [RequiresUnreferencedCode(Strings.UseNonGenericWriteArray)] - [Obsolete(Strings.UseNonGenericWriteArrayObsolete)] - public void WriteArray(ReadOnlySpan value) + internal void WriteArray(ReadOnlySpan value) where T : notnull { #if NET || NETSTANDARD2_1_OR_GREATER diff --git a/src/Tmds.DBus.Protocol/Reader.Array.cs b/src/Tmds.DBus.Protocol/Reader.Array.cs index b9c7d713..5c7373b1 100644 --- a/src/Tmds.DBus.Protocol/Reader.Array.cs +++ b/src/Tmds.DBus.Protocol/Reader.Array.cs @@ -97,7 +97,7 @@ public VariantValue[] ReadArrayOfVariantValue() return items.ToArray(); } - public unsafe T[] ReadArrayOfNumeric() where T : unmanaged + private unsafe T[] ReadArrayOfNumeric() where T : unmanaged { int length = ReadInt32(); if (sizeof(T) > 4)