~ruther/NosSmooth

ref: c076813783b2051c6bdf20dd8862d4e322ec88ef NosSmooth/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/IParameterGenerator.cs -rw-r--r-- 2.2 KiB
c0768137 — František Boháček feat: split packets definitions into separate assembly 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
//  IParameterGenerator.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.CodeDom.Compiler;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using NosSmooth.PacketSerializersGenerator.Data;
using NosSmooth.PacketSerializersGenerator.Errors;

namespace NosSmooth.PacketSerializersGenerator.AttributeGenerators
{
    /// <summary>
    /// Generate serializer and deserializer method parts for the given constructor parameter.
    /// </summary>
    public interface IParameterGenerator
    {
        /// <summary>
        /// Check whether this generator should handle parameter with this attribute.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>Whether to handle this parameter.</returns>
        public bool ShouldHandle(ParameterInfo parameter);

        /// <summary>
        /// Checks the given parameter, returns an error if the parameter cannot be processed.
        /// </summary>
        /// <param name="packet">The packet.</param>
        /// <param name="parameter">The parameter.</param>
        /// <returns>An error, if any.</returns>
        public IError? CheckParameter(PacketInfo packet, ParameterInfo parameter);

        /// <summary>
        /// Generate part for the Serializer method to serialize the given parameter.
        /// </summary>
        /// <param name="textWriter">The text writer to write the code to.</param>
        /// <param name="packetInfo">The packet info to generate for.</param>
        /// <returns>The generated source code.</returns>
        public IError? GenerateSerializerPart(IndentedTextWriter textWriter, PacketInfo packetInfo);

        /// <summary>
        /// Generate part for the Deserializer method to deserialize the given parameter.
        /// </summary>
        /// <param name="textWriter">The text writer to write the code to.</param>
        /// <param name="packetInfo">The packet info to generate for.</param>
        /// <returns>The generated source code.</returns>
        public IError? GenerateDeserializerPart(IndentedTextWriter textWriter, PacketInfo packetInfo);
    }
}
Do not follow this link