Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Generate C# bindings #230

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/bindings/go-apiv2/**/*.pb.go
/bindings/java/src
/bindings/node/src
/bindings/csharp/src
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PROTOC_GEN_GRPC_JAVA_VERSION := 1.63.0
PROTOC_GEN_JS_VERSION := 3.21.2
GRPC_TOOLS_VERSION := 1.12.4
TS_PROTOC_GEN_VERSION := 0.15.0
GRPC_CSHARP_PLUGIN_VERSION := 2.64.0

# This is the commit hash for the https://github.com/googleapis/googleapis repo
GRPC_STATUS_VERSION := f36c65081b19e0758ef5696feca27c7dcee5475e
Expand Down Expand Up @@ -215,6 +216,27 @@ $(TS_PROTOC_GEN):
@mkdir -p $(dir $(TS_PROTOC_GEN))
@touch $(TS_PROTOC_GEN)

# GRPC_CSHARP_PLUGIN points to the marker file for the installed version.
#
# If GRPC_CSHARP_PLUGIN_VERSION is changed, the binary will be re-downloaded.
#
# TODO: no arm mac version
GRPC_CSHARP_PLUGIN := $(CACHE_VERSIONS)/grpc_csharp_plugin/$(GRPC_CSHARP_PLUGIN_VERSION)
$(GRPC_CSHARP_PLUGIN):
@rm -f $(CACHE_BIN)/grpc_csharp_plugin
@mkdir -p $(CACHE_BIN)
$(eval GRPC_CSHARP_PLUGIN_TMP := $(shell mktemp -d))
curl -sSL \
"https://www.nuget.org/api/v2/package/Grpc.Tools/$(GRPC_CSHARP_PLUGIN_VERSION)" \
-o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg"
unzip -o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg" -d "$(GRPC_CSHARP_PLUGIN_TMP)" tools/macosx_x64/grpc_csharp_plugin
mv "$(GRPC_CSHARP_PLUGIN_TMP)/tools/macosx_x64/grpc_csharp_plugin" "$(CACHE_BIN)"
chmod +x "$(CACHE_BIN)/grpc_csharp_plugin"
@rm -rf $(GRPC_CSHARP_PLUGIN_TMP)
@rm -rf $(dir $(GRPC_CSHARP_PLUGIN))
@mkdir -p $(dir $(GRPC_CSHARP_PLUGIN))
@touch $(GRPC_CSHARP_PLUGIN)

.DEFAULT_GOAL := all

.PHONY: all
Expand All @@ -223,7 +245,7 @@ all: lint javabindings nodebindings
# deps allows us to install deps without running any checks.

.PHONY: deps
deps: $(BUF) $(PROTOC) $(PROTOC_GEN_DOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GRPC_JAVA) $(PROTOC_GEN_JS) $(GRPC_TOOLS) $(TS_PROTOC_GEN)
deps: $(BUF) $(PROTOC) $(PROTOC_GEN_DOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GRPC_JAVA) $(PROTOC_GEN_JS) $(GRPC_TOOLS) $(TS_PROTOC_GEN) $(GRPC_CSHARP_PLUGIN)

.PHONY: lint
lint: https
Expand Down
8 changes: 8 additions & 0 deletions bindings/csharp/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
7 changes: 7 additions & 0 deletions bindings/csharp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# fabric-protos

C# bindings for [Hyperledger Fabric protocol buffers](https://github.com/hyperledger/fabric-protos)

## Usage

TBC
118 changes: 106 additions & 12 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: v2
managed:
enabled: true
override:
- file_option: csharp_namespace_prefix
value: Hyperledger.Fabric.Protos
- file_option: java_multiple_files
value: true
- file_option: java_package_prefix
Expand All @@ -11,97 +13,189 @@ managed:
- file_option: java_outer_classname
path: common/configtx.proto
value: ConfigTxProto
- file_option: csharp_namespace
path: ledger/queryresult/kv_query_result.proto
value: Hyperledger.Fabric.Protos.Ledger.QueryResult
- file_option: java_outer_classname
path: ledger/queryresult/kv_query_result.proto
value: KVQueryResultProto
- file_option: java_package
path: ledger/queryresult/kv_query_result.proto
value: org.hyperledger.fabric.protos.ledger.queryresult
- file_option: csharp_namespace
path: ledger/rwset/kvrwset/kv_rwset.proto
value: Hyperledger.Fabric.Protos.Ledger.RWSet.KVRWSet
- file_option: java_outer_classname
path: ledger/rwset/kvrwset/kv_rwset.proto
value: KVRWSetProto
- file_option: java_package
path: ledger/rwset/kvrwset/kv_rwset.proto
value: org.hyperledger.fabric.protos.ledger.rwset.kvrwset
- file_option: csharp_namespace
path: ledger/rwset/rwset.proto
value: Hyperledger.Fabric.Protos.Ledger.RWSet
- file_option: java_outer_classname
path: ledger/rwset/rwset.proto
value: RWSetProto
- file_option: java_package
path: ledger/rwset/rwset.proto
value: org.hyperledger.fabric.protos.ledger.rwset
- file_option: csharp_namespace
path: msp/identities.proto
value: Hyperledger.Fabric.Protos.MSP
- file_option: csharp_namespace
path: msp/msp_config.proto
value: Hyperledger.Fabric.Protos.MSP
- file_option: java_outer_classname
path: msp/msp_config.proto
value: MSPConfigProto
- file_option: java_outer_classname
path: msp/msp_principal.proto
value: MSPPrincipalProto
- file_option: java_package
path: google/rpc/status.proto
value: com.google.rpc
- file_option: java_package
path: ledger/queryresult/kv_query_result.proto
value: org.hyperledger.fabric.protos.ledger.queryresult
- file_option: java_package
path: ledger/rwset/kvrwset/kv_rwset.proto
value: org.hyperledger.fabric.protos.ledger.rwset.kvrwset
- file_option: java_package
path: ledger/rwset/rwset.proto
value: org.hyperledger.fabric.protos.ledger.rwset
- file_option: java_package
path: msp/msp_principal.proto
value: org.hyperledger.fabric.protos.common
- file_option: csharp_namespace
path: google/rpc/status.proto
value: Google.Rpc
- file_option: java_package
path: google/rpc/status.proto
value: com.google.rpc
- file_option: csharp_namespace
path: orderer/etcdraft/configuration.proto
value: Hyperledger.Fabric.Protos.Orderer.EtcdRaft
- file_option: java_package
path: orderer/etcdraft/configuration.proto
value: org.hyperledger.fabric.protos.orderer.etcdraft
- file_option: csharp_namespace
path: orderer/etcdraft/metadata.proto
value: Hyperledger.Fabric.Protos.Orderer.EtcdRaft
- file_option: java_package
path: orderer/etcdraft/metadata.proto
value: org.hyperledger.fabric.protos.orderer.etcdraft
- file_option: csharp_namespace
path: orderer/smartbft/configuration.proto
value: Hyperledger.Fabric.Protos.Orderer.SmartBFT
- file_option: csharp_namespace
path: peer/chaincode.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/chaincode.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/chaincode_event.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/chaincode_event.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/chaincode_shim.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/chaincode_shim.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/collection.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/collection.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/configuration.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/configuration.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/events.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/events.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/lifecycle/chaincode_definition.proto
value: Hyperledger.Fabric.Protos.Peer.Lifecycle
- file_option: java_package
path: peer/lifecycle/chaincode_definition.proto
value: org.hyperledger.fabric.protos.peer.lifecycle
- file_option: csharp_namespace
path: peer/lifecycle/db.proto
value: Hyperledger.Fabric.Protos.Peer.Lifecycle
- file_option: java_package
path: peer/lifecycle/db.proto
value: org.hyperledger.fabric.protos.peer.lifecycle
- file_option: csharp_namespace
path: peer/lifecycle/lifecycle.proto
value: Hyperledger.Fabric.Protos.Peer.Lifecycle
- file_option: java_package
path: peer/lifecycle/lifecycle.proto
value: org.hyperledger.fabric.protos.peer.lifecycle
- file_option: csharp_namespace
path: peer/peer.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/peer.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/policy.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/policy.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/proposal.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/proposal.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/proposal_response.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/proposal_response.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/query.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/query.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/resources.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/resources.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/signed_cc_dep_spec.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/signed_cc_dep_spec.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/snapshot.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/snapshot.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: peer/transaction.proto
value: Hyperledger.Fabric.Protos.Peer
- file_option: java_package
path: peer/transaction.proto
value: org.hyperledger.fabric.protos.peer
- file_option: csharp_namespace
path: transientstore/transientstore.proto
value: Hyperledger.Fabric.Protos.TransientStore
plugins:
- protoc_builtin: csharp
out: bindings/csharp/src
opt:
- base_namespace=
- local: grpc_csharp_plugin
out: bindings/csharp/src
opt:
- base_namespace=
- local: protoc-gen-doc
out: docs
opt:
Expand Down
Loading