Skip to content

Commit 5788f30

Browse files
committed
Refine Comments in Samples
Clarify some existing comments, add additional comments, and clean up some formatting.
1 parent 52570ee commit 5788f30

9 files changed

+47
-34
lines changed

samples/Samples/Sample02_HandlingDynamicObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
namespace Samples
3030
{
3131
/// <summary>
32-
/// A sample code for explore MessagePackObject.
32+
/// A sample code for explore MessagePackObject.
3333
/// </summary>
3434
[TestFixture]
3535
public class HandlingDynamicObjectSample
@@ -91,7 +91,7 @@ public void SerializeThenDeserialize()
9191
// byte[] is byte[], as you know.
9292
Debug.WriteLine( "Image : {0}({1})", asDictionary[ "Image" ], asDictionary[ "Image" ].UnderlyingType );
9393

94-
// 4. Now MessagePackSerializer handle MessagePackObject directly.
94+
// 4. Now MessagePackSerializer handles MessagePackObject directly.
9595
var mpo = serializer.ToMessagePackObject( targetObject );
9696
var asDictionary2 = mpo.AsDictionary();
9797
Debug.WriteLine( "---- ToMessagePackObject ----" );
@@ -100,7 +100,7 @@ public void SerializeThenDeserialize()
100100
Debug.WriteLine( "Date : {0}({1})", asDictionary2[ "Date" ], asDictionary2[ "Date" ].UnderlyingType );
101101
Debug.WriteLine( "Image : {0}({1})", asDictionary2[ "Image" ], asDictionary2[ "Image" ].UnderlyingType );
102102

103-
// reversing
103+
// 5. Use MessagePackSerializer to deserialize target object from MessagePackObject
104104
var targetObject2 = serializer.FromMessagePackObject( mpo );
105105
Debug.WriteLine( "---- FromMessagePackObject ----" );
106106
Debug.WriteLine( "Id : {0}", targetObject2.Id );

samples/Samples/Sample03_SerializationContextAndOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
namespace Samples
3030
{
3131
/// <summary>
32-
/// A sample code to describe SerializationContext usage.
32+
/// A sample code to describe SerializationContext usage.
3333
/// </summary>
3434
[TestFixture]
3535
public class SerializationContextAndOptionsSample

samples/Samples/Sample04_CustomSerializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
namespace Samples
3030
{
3131
/// <summary>
32-
/// A sample code to describe SerializationContext usage.
32+
/// A sample code to describe SerializationContext usage.
3333
/// </summary>
3434
[TestFixture]
3535
public class CustomSerializerSample
@@ -50,7 +50,7 @@ public void RegisterAndUseCustomSerializer()
5050
// 3. Get a serializer instance with customized settings.
5151
var serializer = MessagePackSerializer.Get<DateTime>( context );
5252

53-
// Test it.
53+
// 4. Test Serialization and Deserialization.
5454
var dateTime = DateTime.Now;
5555
serializer.Pack( stream, dateTime );
5656
stream.Position = 0;
@@ -61,7 +61,7 @@ public void RegisterAndUseCustomSerializer()
6161
}
6262

6363
/// <summary>
64-
/// A custom serializer sample: Serialize <see cref="System.DateTime"/> as UTC.
64+
/// A custom serializer sample: Serialize <see cref="System.DateTime"/> as UTC.
6565
/// </summary>
6666
public class NetUtcDateTimeSerializer : MessagePackSerializer<DateTime>
6767
{

samples/Samples/Sample05_PackableAndUnpackable.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
namespace Samples
3030
{
3131
/// <summary>
32-
/// A sample code to describe SerializationContext usage.
32+
/// A sample code to describe SerializationContext usage.
3333
/// </summary>
3434
[TestFixture]
3535
public class PackageAndUnpackableSample
@@ -51,11 +51,11 @@ public void RegisterAndUseCustomSerializer()
5151
}
5252

5353
/// <summary>
54-
/// A custom serializer sample: Serialize <see cref="System.DateTime"/> as UTC.
54+
/// A custom serializer sample: Serialize <see cref="System.DateTime"/> as UTC.
5555
/// </summary>
5656
public class PackableUnpackableObject : IPackable, IUnpackable
5757
{
58-
// Imagine whien you cannot use auto-generated serializer so you have to implement custom serializer for own type easily.
58+
// Imagine when you cannot use auto-generated serializer so you have to implement custom serializer for own type easily.
5959
public long Id { get; set; }
6060
public string Name { get; set; }
6161

samples/Samples/Sample06_CustomAttributes.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626

2727
namespace Samples
2828
{
29-
// You can tweak serialization behavior via custom attributes.
30-
public class MessagePackMemberSample
29+
/// <summary>
30+
/// Sample code to describe MessagePackMember usage.
31+
/// </summary>
32+
/// <remarks>You can tweak serialization behavior via custom attributes.</remarks>
33+
public class MessagePackMemberSample
3134
{
3235
[MessagePackMember(
3336
0, // Specify 0 based index for serialized array. You should specify this value to ensure interoperability with other platform bindings.

samples/Samples/Sample07_ConstructorBasedDeserialization.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
namespace Samples
2828
{
2929
/// <summary>
30-
/// A sample to describe constructor related behavior.
30+
/// A sample to describe constructor related behavior.
3131
/// </summary>
3232
[TestFixture]
3333
public class ConstructorBasedDeserializationSample
3434
{
3535
/// <summary>
36-
/// Demonstrates constructor based deserialization.
36+
/// Demonstrates constructor based deserialization.
3737
/// </summary>
3838
[Test]
3939
public void DoConstructorBasedDeserialization()
@@ -62,7 +62,7 @@ public void DoConstructorBasedDeserialization()
6262
}
6363

6464
/// <summary>
65-
/// "Record" class which has getters and parameterful constructor.
65+
/// "Record" class which has getters and parameterful constructor.
6666
/// </summary>
6767
public class MySimpleRecordClass
6868
{
@@ -75,8 +75,8 @@ public MySimpleRecordClass( string name )
7575
}
7676

7777
/// <summary>
78-
/// A example class which has getters and parameterless and parameterful constructor,
79-
/// and the parameterful constructor is qualified with MessagePackDeserializationConstructor.
78+
/// A example class which has getters and parameterless and parameterful constructor,
79+
/// and the parameterful constructor is qualified with MessagePackDeserializationConstructor.
8080
/// </summary>
8181
public class MyComplexRecordClass
8282
{

samples/Samples/Sample08_Polymorphism.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
namespace Samples
2929
{
3030
/// <summary>
31-
/// A sample to describe polymorphism.
31+
/// A sample to describe polymorphism.
3232
/// </summary>
3333
[TestFixture]
3434
public class PolymorphismSample
3535
{
3636
/// <summary>
37-
/// Demonstrates basic polymorphism.
37+
/// Demonstrates basic polymorphism.
3838
/// </summary>
3939
[Test]
4040
public void Polymorphism()
@@ -78,7 +78,7 @@ public void Polymorphism()
7878
}
7979

8080
/// <summary>
81-
/// Demonstrates polymorphism without enclosing type and its attributes.
81+
/// Demonstrates polymorphism without enclosing type and its attributes.
8282
/// </summary>
8383
[Test]
8484
public void DirectPolymorphism()
@@ -153,40 +153,41 @@ public class PolymorphicHolder
153153
}
154154

155155
/// <summary>
156-
/// Sample base type.
156+
/// Sample base type.
157157
/// </summary>
158158
public interface IFileSystemObject
159159
{
160160
string Path { get; set; }
161161
}
162162

163163
/// <summary>
164-
/// Sample derived type 1.
164+
/// Sample derived type 1.
165165
/// </summary>
166166
public class FileObject : IFileSystemObject
167167
{
168168
public string Path { get; set; }
169169
}
170170

171171
/// <summary>
172-
/// Sample derived type 2.
172+
/// Sample derived type 2.
173173
/// </summary>
174174
public class DirectoryObject : IFileSystemObject
175175
{
176176
public string Path { get; set; }
177177
}
178178

179179
/// <summary>
180-
/// Sample type verifier.
180+
/// Sample type verifier.
181181
/// </summary>
182182
public static class SampleTypeVerifier
183183
{
184-
/// <summary>
185-
/// Sample type verifier. The signature of this method is important.
186-
/// </summary>
187-
/// <param name="context">The context which has information of deserializing type.</param>
188-
/// <returns>True for accepting; otherwise, false.</returns>
189-
public static bool Verify( PolymorphicTypeVerificationContext context )
184+
/// <summary>
185+
/// Sample type verifier.
186+
/// </summary>
187+
/// <remarks>The signature of this method is important.</remarks>
188+
/// <param name="context">The context which has information of deserializing type.</param>
189+
/// <returns>True for accepting; otherwise, false.</returns>
190+
public static bool Verify( PolymorphicTypeVerificationContext context )
190191
{
191192
// You should put type verification logic to prevent unexpected code execution via specified type.
192193
// 1. Check context.LoadingAssemblyName here to verify the assembly is known for you.

samples/Samples/Sample09_Async.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727

2828
namespace Samples
2929
{
30-
[TestFixture]
30+
/// <summary>
31+
/// A sample code to describe async methods.
32+
/// </summary>
33+
[TestFixture]
3134
public class AsyncSample
3235
{
33-
/// <summary>
34-
/// Demonstrates async methods.
35-
/// </summary>
36+
/// <summary>
37+
/// Has object serialized and deserialized asynchronously.
38+
/// </summary>
3639
[Test]
3740
public async Task RunAsync()
3841
{

samples/Samples/Sample10_ByteArrayBased.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@
2626

2727
namespace Samples
2828
{
29+
/// <summary>
30+
/// A sample code to describe byte array based behavior.
31+
/// </summary>
2932
[TestFixture]
3033
public class Sample10_ByteArrayBased
3134
{
35+
/// <summary>
36+
/// Uses byte array for serialization and deserialization.
37+
/// </summary>
3238
[Test]
3339
public void SimpleBufferCase()
3440
{

0 commit comments

Comments
 (0)