Repository: goadesign/goa (go)

Issue:
Unable to use same ResultType as StreamingResult in more than one method. 
If I use same `ResultType` as `StreamingResult` in more than one method, `NewResultTypeView(v)` accepts only single `MethodResponse` type that is generated for the first declared method in DSL.

simple repro:
```go
package design

import (
	. "goa.design/goa/v3/dsl"
)

var _ = API("streamer", func() {
	Server("Streamer", func() {
		Services("Streamer")
	})
})

var _ = Service("Streamer", func() {
	Method("subscribe", func() {
		Payload(func() {
			Field(1, "eventId", Int64, func() {
				Example(101)
			})
		})
		StreamingResult(Event)
		GRPC(func() {
			Response(CodeOK)
		})
	})

	Method("resume", func() {
		Payload(func() {
			Field(1, "eventId", Int64, func() {
				Example(101)
			})
		})
		StreamingResult(Event)
		GRPC(func() {
			Response(CodeOK)
		})
	})
})

var Event = ResultType("Event", func() {
	Field(1, "message", String, "Message sent to the server")
	Field(2, "action", String, func() {
		Enum("added")
	})
	Field(3, "added_at", String, "Time at which the message was added", func() {
		Format(FormatDateTime)
	})
	Required("message", "action", "added_at")
})
```

- go version: `go version go1.18.7 linux/amd64`
- goa version: `Goa version v3.10.1`

Compile error can be found in generated file at -> `gen/grpc/streamer/client/client.go`

Maybe related to this issue/fix: https://github.com/goadesign/goa/issues/2723

Pull request description:
Qualify streaming CLI payload builder name
Multiple builder methods may be needed for multiple source types.

Fix #3171 

Patch:
diff --git a/codegen/cli/cli.go b/codegen/cli/cli.go
index 9976f852..34f4b822 100644
--- a/codegen/cli/cli.go
+++ b/codegen/cli/cli.go
@@ -308,7 +308,6 @@ func PayloadBuilderSection(buildFunction *BuildFunctionData) *codegen.SectionTem
 // description is the flag description
 // required determines if the flag is required
 // example is an example value for the flag
-//
 func NewFlagData(svcn, en, name, typeName, description string, required bool, example, def interface{}) *FlagData {
 	ex := jsonExample(example)
 	fn := goifyTerms(svcn, en, name)
diff --git a/grpc/codegen/service_data.go b/grpc/codegen/service_data.go
index 85fe8444..e0fbb0cc 100644
--- a/grpc/codegen/service_data.go
+++ b/grpc/codegen/service_data.go
@@ -859,7 +859,7 @@ func buildRequestConvertData(request, payload *expr.AttributeExpr, md []*Metadat
 		// server side
 		var data *InitData
 		{
-			data = buildInitData(request, payload, "message", "v", svcCtx, false, svr, sd)
+			data = buildInitData(request, payload, "message", "v", svcCtx, false, svr, false, sd)
 			data.Name = fmt.Sprintf("New%sPayload", codegen.Goify(e.Name(), true))
 			data.Description = fmt.Sprintf("%s builds the payload of the %q endpoint of the %q service from the gRPC request type.", data.Name, e.Name(), svc.Name)
 			for _, m := range md {
@@ -895,7 +895,7 @@ func buildRequestConvertData(request, payload *expr.AttributeExpr, md []*Metadat
 		data *InitData
 	)
 	{
-		data = buildInitData(payload, request, "payload", "message", svcCtx, true, svr, sd)
+		data = buildInitData(payload, request, "payload", "message", svcCtx, true, svr, false, sd)
 		data.Description = fmt.Sprintf("%s builds the gRPC request type from the payload of the %q endpoint of the %q service.", data.Name, e.Name(), svc.Name)
 	}
 	return &ConvertData{
@@ -929,7 +929,7 @@ func buildResponseConvertData(response, result *expr.AttributeExpr, svcCtx *code
 
 		var data *InitData
 		{
-			data = buildInitData(result, response, "result", "message", svcCtx, true, svr, sd)
+			data = buildInitData(result, response, "result", "message", svcCtx, true, svr, false, sd)
 			data.Description = fmt.Sprintf("%s builds the gRPC response type from the result of the %q endpoint of the %q service.", data.Name, e.Name(), svc.Name)
 		}
 		return &ConvertData{
@@ -945,7 +945,7 @@ func buildResponseConvertData(response, result *expr.AttributeExpr, svcCtx *code
 
 	var data *InitData
 	{
-		data = buildInitData(response, result, "message", "result", svcCtx, false, svr, sd)
+		data = buildInitData(response, result, "message", "result", svcCtx, false, svr, false, sd)
 		data.Name = fmt.Sprintf("New%sResult", codegen.Goify(e.Name(), true))
 		data.Description = fmt.Sprintf("%s builds the result type of the %q endpoint of the %q service from the gRPC response type.", data.Name, e.Name(), svc.Name)
 		for _, m := range hdrs {
@@ -1000,7 +1000,7 @@ func buildResponseConvertData(response, result *expr.AttributeExpr, svcCtx *code
 // svcCtx is the attribute context for service type
 // proto if true indicates the target type is a protocol buffer type
 // svr if true indicates the code is generated for conversion server side
-func buildInitData(source, target *expr.AttributeExpr, sourceVar, targetVar string, svcCtx *codegen.AttributeContext, proto, svr bool, sd *ServiceData) *InitData {
+func buildInitData(source, target *expr.AttributeExpr, sourceVar, targetVar string, svcCtx *codegen.AttributeContext, proto, svr, usesrc bool, sd *ServiceData) *InitData {
 	var (
 		name     string
 		isStruct bool
@@ -1024,6 +1024,9 @@ func buildInitData(source, target *expr.AttributeExpr, sourceVar, targetVar stri
 			name += "Proto"
 		}
 		isStruct = expr.IsObject(target.Type) || expr.IsUnion(target.Type)
+		if _, ok := source.Type.(expr.UserType); ok && usesrc {
+			name += protoBufGoTypeName(source, sd.Scope)
+		}
 		n := protoBufGoTypeName(target, sd.Scope)
 		if !isStruct {
 			// If target is array, map, or primitive the name will be suffixed with
@@ -1103,7 +1106,7 @@ func buildErrorConvertData(ge *expr.GRPCErrorExpr, e *expr.GRPCEndpointExpr, sd
 
 		var data *InitData
 		{
-			data = buildInitData(ge.ErrorExpr.AttributeExpr, ge.Response.Message, "er", "message", svcCtx, true, svr, sd)
+			data = buildInitData(ge.ErrorExpr.AttributeExpr, ge.Response.Message, "er", "message", svcCtx, true, svr, false, sd)
 			data.Name = fmt.Sprintf("New%s%sError", codegen.Goify(e.Name(), true), codegen.Goify(ge.Name, true))
 			data.Description = fmt.Sprintf("%s builds the gRPC error response type from the error of the %q endpoint of the %q service.", data.Name, e.Name(), svc.Name)
 		}
@@ -1120,7 +1123,7 @@ func buildErrorConvertData(ge *expr.GRPCErrorExpr, e *expr.GRPCEndpointExpr, sd
 
 	var data *InitData
 	{
-		data = buildInitData(ge.Response.Message, ge.ErrorExpr.AttributeExpr, "message", "er", svcCtx, false, svr, sd)
+		data = buildInitData(ge.Response.Message, ge.ErrorExpr.AttributeExpr, "message", "er", svcCtx, false, svr, false, sd)
 		data.Name = fmt.Sprintf("New%s%sError", codegen.Goify(e.Name(), true), codegen.Goify(ge.Name, true))
 		data.Description = fmt.Sprintf("%s builds the error type of the %q endpoint of the %q service from the gRPC error response type.", data.Name, e.Name(), svc.Name)
 	}
@@ -1139,19 +1142,19 @@ func buildErrorConvertData(ge *expr.GRPCErrorExpr, e *expr.GRPCEndpointExpr, sd
 // svr param indicates that the stream data is built for the server.
 func buildStreamData(e *expr.GRPCEndpointExpr, sd *ServiceData, svr bool) *StreamData {
 	var (
-		varn      string
-		intName   string
-		svcInt    string
-		sendName  string
-		sendDesc  string
-		sendRef   string
-		sendType  *ConvertData
-		recvName  string
-		recvDesc  string
-		recvRef   string
-		recvType  *ConvertData
-		mustClose bool
-		typ       string
+		varn        string
+		intName     string
+		svcInt      string
+		sendName    string
+		sendDesc    string
+		sendRef     string
+		sendConvert *ConvertData
+		recvName    string
+		recvDesc    string
+		recvRef     string
+		recvConvert *ConvertData
+		mustClose   bool
+		typ         string
 
 		svc            = sd.Service
 		ed             = sd.Endpoint(e.Name())
@@ -1172,23 +1175,23 @@ func buildStreamData(e *expr.GRPCEndpointExpr, sd *ServiceData, svr bool) *Strea
 			if e.MethodExpr.Result.Type != expr.Empty {
 				sendName = md.ServerStream.SendName
 				sendRef = ed.ResultRef
-				sendType = &ConvertData{
+				sendConvert = &ConvertData{
 					SrcName: resCtx.Scope.Name(result, resCtx.Pkg(result), resCtx.Pointer, resCtx.UseDefault),
 					SrcRef:  resCtx.Scope.Ref(result, resCtx.Pkg(result)),
 					TgtName: protoBufGoFullTypeName(e.Response.Message, sd.PkgName, sd.Scope),
 					TgtRef:  protoBufGoFullTypeRef(e.Response.Message, sd.PkgName, sd.Scope),
-					Init:    buildInitData(result, e.Response.Message, resVar, "v", resCtx, true, svr, sd),
+					Init:    buildInitData(result, e.Response.Message, resVar, "v", resCtx, true, svr, true, sd),
 				}
 			}
 			if e.MethodExpr.StreamingPayload.Type != expr.Empty {
 				recvName = md.ServerStream.RecvName
 				recvRef = svcCtx.Scope.Ref(e.MethodExpr.StreamingPayload, svcCtx.Pkg(e.MethodExpr.StreamingPayload))
-				recvType = &ConvertData{
+				recvConvert = &ConvertData{
 					SrcName:    protoBufGoFullTypeName(e.StreamingRequest, sd.PkgName, sd.Scope),
 					SrcRef:     protoBufGoFullTypeRef(e.StreamingRequest, sd.PkgName, sd.Scope),
 					TgtName:    svcCtx.Scope.Name(e.MethodExpr.StreamingPayload, svcCtx.Pkg(e.MethodExpr.StreamingPayload), svcCtx.Pointer, svcCtx.UseDefault),
 					TgtRef:     recvRef,
-					Init:       buildInitData(e.StreamingRequest, e.MethodExpr.StreamingPayload, "v", "spayload", svcCtx, false, svr, sd),
+					Init:       buildInitData(e.StreamingRequest, e.MethodExpr.StreamingPayload, "v", "spayload", svcCtx, false, svr, true, sd),
 					Validation: addValidation(e.StreamingRequest, "stream", sd, true),
 				}
 			}
@@ -1201,33 +1204,33 @@ func buildStreamData(e *expr.GRPCEndpointExpr, sd *ServiceData, svr bool) *Strea
 			if e.MethodExpr.StreamingPayload.Type != expr.Empty {
 				sendName = md.ClientStream.SendName
 				sendRef = svcCtx.Scope.Ref(e.MethodExpr.StreamingPayload, svcCtx.Pkg(e.MethodExpr.StreamingPayload))
-				sendType = &ConvertData{
+				sendConvert = &ConvertData{
 					SrcName: svcCtx.Scope.Name(e.MethodExpr.StreamingPayload, svcCtx.Pkg(e.MethodExpr.StreamingPayload), svcCtx.Pointer, svcCtx.UseDefault),
 					SrcRef:  sendRef,
 					TgtName: protoBufGoFullTypeName(e.StreamingRequest, sd.PkgName, sd.Scope),
 					TgtRef:  protoBufGoFullTypeRef(e.StreamingRequest, sd.PkgName, sd.Scope),
-					Init:    buildInitData(e.MethodExpr.StreamingPayload, e.StreamingRequest, "spayload", "v", svcCtx, true, svr, sd),
+					Init:    buildInitData(e.MethodExpr.StreamingPayload, e.StreamingRequest, "spayload", "v", svcCtx, true, svr, true, sd),
 				}
 			}
 			if e.MethodExpr.Result.Type != expr.Empty {
 				recvName = md.ClientStream.RecvName
 				recvRef = ed.ResultRef
-				recvType = &ConvertData{
+				recvConvert = &ConvertData{
 					SrcName:    protoBufGoFullTypeName(e.Response.Message, sd.PkgName, sd.Scope),
 					SrcRef:     protoBufGoFullTypeRef(e.Response.Message, sd.PkgName, sd.Scope),
 					TgtName:    resCtx.Scope.Name(result, resCtx.Pkg(result), resCtx.Pointer, resCtx.UseDefault),
 					TgtRef:     resCtx.Scope.Ref(result, resCtx.Pkg(result)),
-					Init:       buildInitData(e.Response.Message, result, "v", resVar, resCtx, false, svr, sd),
+					Init:       buildInitData(e.Response.Message, result, "v", resVar, resCtx, false, svr, true, sd),
 					Validation: addValidation(e.Response.Message, "stream", sd, false),
 				}
 			}
 			mustClose = md.ClientStream.MustClose
 		}
-		if sendType != nil {
-			sendDesc = fmt.Sprintf("%s streams instances of %q to the %q endpoint gRPC stream.", sendName, sendType.TgtName, md.Name)
+		if sendConvert != nil {
+			sendDesc = fmt.Sprintf("%s streams instances of %q to the %q endpoint gRPC stream.", sendName, sendConvert.TgtName, md.Name)
 		}
-		if recvType != nil {
-			recvDesc = fmt.Sprintf("%s reads instances of %q from the %q endpoint gRPC stream.", recvName, recvType.SrcName, md.Name)
+		if recvConvert != nil {
+			recvDesc = fmt.Sprintf("%s reads instances of %q from the %q endpoint gRPC stream.", recvName, recvConvert.SrcName, md.Name)
 		}
 	}
 	return &StreamData{
@@ -1239,11 +1242,11 @@ func buildStreamData(e *expr.GRPCEndpointExpr, sd *ServiceData, svr bool) *Strea
 		SendName:         sendName,
 		SendDesc:         sendDesc,
 		SendRef:          sendRef,
-		SendConvert:      sendType,
+		SendConvert:      sendConvert,
 		RecvName:         recvName,
 		RecvDesc:         recvDesc,
 		RecvRef:          recvRef,
-		RecvConvert:      recvType,
+		RecvConvert:      recvConvert,
 		MustClose:        mustClose,
 	}
 }


Test patch:
diff --git a/grpc/codegen/streaming_test.go b/grpc/codegen/streaming_test.go
index 6c522e9c..fc165361 100644
--- a/grpc/codegen/streaming_test.go
+++ b/grpc/codegen/streaming_test.go
@@ -67,6 +67,9 @@ func TestStreaming(t *testing.T) {
 			{"server-stream-send", &testdata.ServerStreamingMapServerSendCode},
 			{"client-stream-recv", &testdata.ServerStreamingMapClientRecvCode},
 		}},
+		{"server-streaming-shared-result", testdata.ServerStreamingSharedResultRPCDSL, []*sectionExpectation{
+			{"client-stream-recv", &testdata.ServerStreamingServerRPCSharedResultRecvCode},
+		}},
 
 		// streaming payload
 
@@ -112,7 +115,6 @@ func TestStreaming(t *testing.T) {
 			}
 			for _, s := range c.Sections {
 				var (
-					code     string
 					path     string
 					sections []*codegen.SectionTemplate
 				)
@@ -124,8 +126,9 @@ func TestStreaming(t *testing.T) {
 					path = clientfs[0].Path
 				}
 				seclen := len(sections)
-				if seclen > 0 {
-					code = codegen.SectionCode(t, sections[0])
+				var code []string
+				for _, section := range sections {
+					code = append(code, codegen.SectionCode(t, section))
 				}
 				switch {
 				case seclen == 0 && s.Code == nil:
@@ -137,8 +140,9 @@ func TestStreaming(t *testing.T) {
 					// Test failed: section exists in file, but no code expected.
 					t.Errorf("invalid code for %s: got %d %s sections, expected 0.\n%s", path, seclen, s.Name, code)
 				default:
-					if code != *s.Code {
-						t.Errorf("invalid code for %s %s section, got:\n%s\ngot vs. expected:\n%s", path, s.Name, code, codegen.Diff(t, code, *s.Code))
+					gen := strings.Join(code, "\n")
+					if gen != *s.Code {
+						t.Errorf("invalid code for %s %s section, got:\n%s\ngot vs. expected:\n%s", path, s.Name, gen, codegen.Diff(t, gen, *s.Code))
 					}
 				}
 			}
diff --git a/grpc/codegen/testdata/client_type_code.go b/grpc/codegen/testdata/client_type_code.go
index b8e414ce..cae72653 100644
--- a/grpc/codegen/testdata/client_type_code.go
+++ b/grpc/codegen/testdata/client_type_code.go
@@ -297,7 +297,7 @@ func ValidateMethodUnaryRPCWithErrorsBadRequestError(errmsg *service_unary_rpc_w
 }
 `
 
-const BidirectionalStreamingRPCSameTypeClientTypeCode = `func NewUserType(v *service_bidirectional_streaming_rpc_same_typepb.MethodBidirectionalStreamingRPCSameTypeResponse) *servicebidirectionalstreamingrpcsametype.UserType {
+const BidirectionalStreamingRPCSameTypeClientTypeCode = `func NewMethodBidirectionalStreamingRPCSameTypeResponseUserType(v *service_bidirectional_streaming_rpc_same_typepb.MethodBidirectionalStreamingRPCSameTypeResponse) *servicebidirectionalstreamingrpcsametype.UserType {
 	result := &servicebidirectionalstreamingrpcsametype.UserType{
 		B: v.B,
 	}
@@ -308,7 +308,7 @@ const BidirectionalStreamingRPCSameTypeClientTypeCode = `func NewUserType(v *ser
 	return result
 }
 
-func NewProtoMethodBidirectionalStreamingRPCSameTypeStreamingRequest(spayload *servicebidirectionalstreamingrpcsametype.UserType) *service_bidirectional_streaming_rpc_same_typepb.MethodBidirectionalStreamingRPCSameTypeStreamingRequest {
+func NewProtoUserTypeMethodBidirectionalStreamingRPCSameTypeStreamingRequest(spayload *servicebidirectionalstreamingrpcsametype.UserType) *service_bidirectional_streaming_rpc_same_typepb.MethodBidirectionalStreamingRPCSameTypeStreamingRequest {
 	v := &service_bidirectional_streaming_rpc_same_typepb.MethodBidirectionalStreamingRPCSameTypeStreamingRequest{
 		B: spayload.B,
 	}
diff --git a/grpc/codegen/testdata/dsls.go b/grpc/codegen/testdata/dsls.go
index 58bc53ff..ffa3b0f8 100644
--- a/grpc/codegen/testdata/dsls.go
+++ b/grpc/codegen/testdata/dsls.go
@@ -179,6 +179,22 @@ var ServerStreamingMapDSL = func() {
 	})
 }
 
+var ServerStreamingSharedResultRPCDSL = func() {
+	var UT = Type("UserType", func() {
+		Field(1, "IntField", Int)
+	})
+	Service("ServiceServerStreamingRPC", func() {
+		Method("MethodServerStreamingRPC", func() {
+			StreamingResult(UT)
+			GRPC(func() {})
+		})
+		Method("OtherMethodServerStreamingRPC", func() {
+			StreamingResult(UT)
+			GRPC(func() {})
+		})
+	})
+}
+
 var ServerStreamingResultWithViewsDSL = func() {
 	var RT = ResultType("application/vnd.result", func() {
 		TypeName("ResultType")
diff --git a/grpc/codegen/testdata/server_type_code.go b/grpc/codegen/testdata/server_type_code.go
index d4274b6a..923f1e74 100644
--- a/grpc/codegen/testdata/server_type_code.go
+++ b/grpc/codegen/testdata/server_type_code.go
@@ -296,7 +296,7 @@ func NewProtoStreamingMethodResponse() *service_payload_with_mixed_attributespb.
 	return message
 }
 
-func NewAPayload(v *service_payload_with_mixed_attributespb.StreamingMethodStreamingRequest) *servicepayloadwithmixedattributes.APayload {
+func NewStreamingMethodStreamingRequestAPayload(v *service_payload_with_mixed_attributespb.StreamingMethodStreamingRequest) *servicepayloadwithmixedattributes.APayload {
 	spayload := &servicepayloadwithmixedattributes.APayload{
 		Required:        int(v.Required),
 		RequiredDefault: int(v.RequiredDefault),
diff --git a/grpc/codegen/testdata/streaming_code.go b/grpc/codegen/testdata/streaming_code.go
index 7383e3a4..ae871c39 100644
--- a/grpc/codegen/testdata/streaming_code.go
+++ b/grpc/codegen/testdata/streaming_code.go
@@ -12,7 +12,7 @@ var ServerStreamingServerSendCode = `// Send streams instances of
 // "service_server_streaming_user_type_rpcpb.MethodServerStreamingUserTypeRPCResponse"
 // to the "MethodServerStreamingUserTypeRPC" endpoint gRPC stream.
 func (s *MethodServerStreamingUserTypeRPCServerStream) Send(res *serviceserverstreamingusertyperpc.UserType) error {
-	v := NewProtoMethodServerStreamingUserTypeRPCResponse(res)
+	v := NewProtoUserTypeMethodServerStreamingUserTypeRPCResponse(res)
 	return s.stream.Send(v)
 }
 `
@@ -40,7 +40,7 @@ func (s *MethodServerStreamingUserTypeRPCClientStream) Recv() (*serviceserverstr
 	if err != nil {
 		return res, err
 	}
-	return NewUserType(v), nil
+	return NewMethodServerStreamingUserTypeRPCResponseUserType(v), nil
 }
 `
 
@@ -58,7 +58,7 @@ var ServerStreamingResultWithViewsServerSendCode = `// Send streams instances of
 // to the "MethodServerStreamingUserTypeRPC" endpoint gRPC stream.
 func (s *MethodServerStreamingUserTypeRPCServerStream) Send(res *serviceserverstreamingusertyperpc.ResultType) error {
 	vres := serviceserverstreamingusertyperpc.NewViewedResultType(res, s.view)
-	v := NewProtoMethodServerStreamingUserTypeRPCResponse(vres.Projected)
+	v := NewProtoResultTypeViewMethodServerStreamingUserTypeRPCResponse(vres.Projected)
 	return s.stream.Send(v)
 }
 `
@@ -87,7 +87,7 @@ func (s *MethodServerStreamingUserTypeRPCClientStream) Recv() (*serviceserverstr
 	if err != nil {
 		return res, err
 	}
-	proj := NewResultTypeView(v)
+	proj := NewMethodServerStreamingUserTypeRPCResponseResultTypeView(v)
 	vres := &serviceserverstreamingusertyperpcviews.ResultType{Projected: proj, View: s.view}
 	if err := serviceserverstreamingusertyperpcviews.ValidateResultType(vres); err != nil {
 		return nil, err
@@ -108,7 +108,7 @@ var ServerStreamingResultCollectionWithExplicitViewServerSendCode = `// Send str
 // gRPC stream.
 func (s *MethodServerStreamingResultTypeCollectionWithExplicitViewServerStream) Send(res serviceserverstreamingresulttypecollectionwithexplicitview.ResultTypeCollection) error {
 	vres := serviceserverstreamingresulttypecollectionwithexplicitview.NewViewedResultTypeCollection(res, "tiny")
-	v := NewProtoResultTypeCollection(vres.Projected)
+	v := NewProtoResultTypeCollectionViewResultTypeCollection(vres.Projected)
 	return s.stream.Send(v)
 }
 `
@@ -123,7 +123,7 @@ func (s *MethodServerStreamingResultTypeCollectionWithExplicitViewClientStream)
 	if err != nil {
 		return res, err
 	}
-	proj := NewResultTypeCollection(v)
+	proj := NewResultTypeCollectionResultTypeCollection(v)
 	vres := serviceserverstreamingresulttypecollectionwithexplicitviewviews.ResultTypeCollection{Projected: proj, View: "tiny"}
 	if err := serviceserverstreamingresulttypecollectionwithexplicitviewviews.ValidateResultTypeCollection(vres); err != nil {
 		return nil, err
@@ -150,7 +150,7 @@ func (s *MethodServerStreamingRPCClientStream) Recv() (string, error) {
 	if err != nil {
 		return res, err
 	}
-	return NewMethodServerStreamingRPCResponse(v), nil
+	return NewMethodServerStreamingRPCResponseMethodServerStreamingRPCResponse(v), nil
 }
 `
 
@@ -172,7 +172,7 @@ func (s *MethodServerStreamingArrayClientStream) Recv() ([]int, error) {
 	if err != nil {
 		return res, err
 	}
-	return NewMethodServerStreamingArrayResponse(v), nil
+	return NewMethodServerStreamingArrayResponseMethodServerStreamingArrayResponse(v), nil
 }
 `
 
@@ -194,7 +194,32 @@ func (s *MethodServerStreamingMapClientStream) Recv() (map[string]*serviceserver
 	if err != nil {
 		return res, err
 	}
-	return NewMethodServerStreamingMapResponse(v), nil
+	return NewMethodServerStreamingMapResponseMethodServerStreamingMapResponse(v), nil
+}
+`
+
+var ServerStreamingServerRPCSharedResultRecvCode = `// Recv reads instances of
+// "service_server_streaming_rpcpb.MethodServerStreamingRPCResponse" from the
+// "MethodServerStreamingRPC" endpoint gRPC stream.
+func (s *MethodServerStreamingRPCClientStream) Recv() (*serviceserverstreamingrpc.UserType, error) {
+	var res *serviceserverstreamingrpc.UserType
+	v, err := s.stream.Recv()
+	if err != nil {
+		return res, err
+	}
+	return NewMethodServerStreamingRPCResponseUserType(v), nil
+}
+
+// Recv reads instances of
+// "service_server_streaming_rpcpb.OtherMethodServerStreamingRPCResponse" from
+// the "OtherMethodServerStreamingRPC" endpoint gRPC stream.
+func (s *OtherMethodServerStreamingRPCClientStream) Recv() (*serviceserverstreamingrpc.UserType, error) {
+	var res *serviceserverstreamingrpc.UserType
+	v, err := s.stream.Recv()
+	if err != nil {
+		return res, err
+	}
+	return NewOtherMethodServerStreamingRPCResponseUserType(v), nil
 }
 `
 
@@ -223,7 +248,7 @@ func (s *MethodClientStreamingRPCServerStream) Recv() (int, error) {
 	if err != nil {
 		return res, err
 	}
-	return NewMethodClientStreamingRPCStreamingRequest(v), nil
+	return NewMethodClientStreamingRPCStreamingRequestMethodClientStreamingRPCStreamingRequest(v), nil
 }
 `
 
@@ -252,7 +277,7 @@ func (s *MethodClientStreamingRPCClientStream) CloseAndRecv() (string, error) {
 	if err != nil {
 		return res, err
 	}
-	return NewMethodClientStreamingRPCResponse(v), nil
+	return NewMethodClientStreamingRPCResponseMethodClientStreamingRPCResponse(v), nil
 }
 `
 
@@ -283,7 +308,7 @@ var BidirectionalStreamingServerSendCode = `// Send streams instances of
 // to the "MethodBidirectionalStreamingRPC" endpoint gRPC stream.
 func (s *MethodBidirectionalStreamingRPCServerStream) Send(res *servicebidirectionalstreamingrpc.ID) error {
 	vres := servicebidirectionalstreamingrpc.NewViewedID(res, "default")
-	v := NewProtoMethodBidirectionalStreamingRPCResponse(vres.Projected)
+	v := NewProtoIDViewMethodBidirectionalStreamingRPCResponse(vres.Projected)
 	return s.stream.Send(v)
 }
 `
@@ -297,7 +322,7 @@ func (s *MethodBidirectionalStreamingRPCServerStream) Recv() (int, error) {
 	if err != nil {
 		return res, err
 	}
-	return NewMethodBidirectionalStreamingRPCStreamingRequest(v), nil
+	return NewMethodBidirectionalStreamingRPCStreamingRequestMethodBidirectionalStreamingRPCStreamingRequest(v), nil
 }
 `
 
@@ -334,7 +359,7 @@ func (s *MethodBidirectionalStreamingRPCClientStream) Recv() (*servicebidirectio
 	if err != nil {
 		return res, err
 	}
-	proj := NewIDView(v)
+	proj := NewMethodBidirectionalStreamingRPCResponseIDView(v)
 	vres := &servicebidirectionalstreamingrpcviews.ID{Projected: proj, View: "default"}
 	if err := servicebidirectionalstreamingrpcviews.ValidateID(vres); err != nil {
 		return nil, err