diff --git a/.gitignore b/.gitignore index 7130f92..83090c0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /bindings/go-apiv2/**/*.pb.go /bindings/java/src /bindings/node/src +/bindings/csharp/src diff --git a/Makefile b/Makefile index 4cba587..ca25904 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 diff --git a/bindings/csharp/NuGet.Config b/bindings/csharp/NuGet.Config new file mode 100644 index 0000000..584fd5c --- /dev/null +++ b/bindings/csharp/NuGet.Config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bindings/csharp/README.md b/bindings/csharp/README.md new file mode 100644 index 0000000..92d1d77 --- /dev/null +++ b/bindings/csharp/README.md @@ -0,0 +1,7 @@ +# fabric-protos + +C# bindings for [Hyperledger Fabric protocol buffers](https://github.com/hyperledger/fabric-protos) + +## Usage + +TBC diff --git a/buf.gen.yaml b/buf.gen.yaml index e9eea4e..5a1d5dc 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -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 @@ -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: