csharp_protobuf

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: MulanPSL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TmplDefineST = &generator.TemplateHeader{
	Name:     "csharp_protobuf_define_st",
	Filepath: "csharp_protobuf_define_st.tmpl",

	BuiltinTemplateText: `
{{if (ne .DocComment "")}}    {{.DocComment}}
{{end}}    public partial class {{.Name}} : {{.BaseName}}
    {
        partial void OnConstruction()
        {
{{range .Fields}}{{if (ne .ShouldInitCustomType "")}}            {{.Name}} = new {{.ShouldInitCustomType}}();
{{end}}{{if .ShouldInitString}}            {{.Name}} = "";
{{end}}{{end}}        }
        public override string Name()
        {
            return "{{.Name}}";
        }
        public override {{.Name}} NewST()
        {
            return new {{.Name}}();
        }
        public override Byte[] Encode()
        {
            return MessageExtensions.ToByteArray(this);
        }
        public override void Decode(Byte[] bs)
        {
            this.MergeFrom(bs);
        }
{{if .IsMessage}}
        public override UInt32 ProtoID()
        {
            return MessageDef.ProtoID{{.Name}};
        }
        public override {{.Name}} New()
        {
            return NewST();
        }
{{end}}
    }
`,
}
View Source
var TmplProtoFile = &generator.TemplateHeader{
	Name:     "csharp_protobuf_proto_file",
	Filepath: "csharp_protobuf_proto_file.tmpl",

	BuiltinTemplateText: `using System;
using System.Collections.Generic;
{{if (len .DefineSTCode | ne 0)}}using Google.Protobuf;
{{end}}
namespace {{.Namespace}}
{
{{range .DefineSTCode}}{{.}}{{end}}
}
`,
}

Functions

func GenCodeForDefineST

func GenCodeForDefineST(pSet *generator.PrototypeSet, df *generator.DefineST, isMessage bool) (string, error)

func GenFileForMessage

func GenFileForMessage(pSet *generator.PrototypeSet, origFn string) error

func GenFileForSet

func GenFileForSet(pSet *generator.PrototypeSet) error

Types

type Generator

type Generator struct {
}

func (*Generator) Generate

func (*Generator) Lang

func (g *Generator) Lang() string

func (*Generator) NewConfig

func (g *Generator) NewConfig() generator.GeneratorConfig

func (*Generator) Proto

func (g *Generator) Proto() string

type GeneratorConfig

type GeneratorConfig struct {
	Dir           string `json:"dir,omitempty"`
	NamespaceName string `json:"namespace_name,omitempty"`

	ProtoDir string `json:"proto_dir,omitempty"`

	MessageFilename string `json:"message_filename,omitempty"`
	ConstFilename   string `json:"const_filename,omitempty"`

	Plugins []string `json:"plugins,omitempty"`
}

type TmplDefineSTData added in v0.2.0

type TmplDefineSTData struct {
	Name     string
	BaseName string

	DocComment string
	Fields     []*TmplDefineSTDataField

	IsMessage bool

	Plugins map[string]interface{}
}

type TmplDefineSTDataField added in v0.2.0

type TmplDefineSTDataField struct {
	Name        string
	DocComment  string
	LineComment string

	ShouldInitCustomType string
	ShouldInitString     bool

	Plugins map[string]interface{}
}

type TmplProtoFileData added in v0.2.0

type TmplProtoFileData struct {
	Import    []string
	Namespace string

	DefineSTCode []string

	Plugins map[string]interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL