-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For golang/protobuf#1657 Change-Id: I7b2b0c30506706015ce278e6054439c9ad9ef727 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/634815 TryBot-Bypass: Michael Stapelberg <[email protected]> Reviewed-by: Joseph Tsai <[email protected]> Reviewed-by: Damien Neil <[email protected]>
- Loading branch information
1 parent
5f5de33
commit eb7b468
Showing
101 changed files
with
17,785 additions
and
142 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package descriptor_test | ||
|
||
import ( | ||
"testing" | ||
|
||
testopenpb "google.golang.org/protobuf/internal/testprotos/test" | ||
testhybridpb "google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_hybrid" | ||
testopaquepb "google.golang.org/protobuf/internal/testprotos/testeditions/testeditions_opaque" | ||
) | ||
|
||
func TestFileModeEnum(t *testing.T) { | ||
var e any = testopenpb.ForeignEnum_FOREIGN_FOO | ||
if _, ok := e.(interface{ EnumDescriptor() ([]byte, []int) }); !ok { | ||
t.Errorf("Open V1 proto did not have deprecated method EnumDescriptor") | ||
} | ||
var oe any = testopaquepb.ForeignEnum_FOREIGN_FOO | ||
if _, ok := oe.(interface{ EnumDescriptor() ([]byte, []int) }); ok { | ||
t.Errorf("Opaque V0 proto did have deprecated method EnumDescriptor") | ||
} | ||
var he any = testhybridpb.ForeignEnum_FOREIGN_FOO | ||
if _, ok := he.(interface{ EnumDescriptor() ([]byte, []int) }); ok { | ||
t.Errorf("Hybrid proto did have deprecated method EnumDescriptor") | ||
} | ||
} | ||
|
||
func TestFileModeMessage(t *testing.T) { | ||
var p any = &testopenpb.TestAllTypes{} | ||
if _, ok := p.(interface{ Descriptor() ([]byte, []int) }); !ok { | ||
t.Errorf("Open V1 proto did not have deprecated method Descriptor") | ||
} | ||
var op any = &testopaquepb.TestAllTypes{} | ||
if _, ok := op.(interface{ Descriptor() ([]byte, []int) }); ok { | ||
t.Errorf("Opaque V0 mode proto unexpectedly has deprecated Descriptor() method") | ||
} | ||
var hp any = &testhybridpb.TestAllTypes{} | ||
if _, ok := hp.(interface{ EnumDescriptor() ([]byte, []int) }); ok { | ||
t.Errorf("Hybrid proto did have deprecated method EnumDescriptor") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package internal_gengo | ||
|
||
import "google.golang.org/protobuf/types/gofeaturespb" | ||
|
||
func (m *messageInfo) isOpen() bool { | ||
return m.Message.APILevel == gofeaturespb.GoFeatures_API_OPEN | ||
} | ||
|
||
func (m *messageInfo) isHybrid() bool { | ||
return m.Message.APILevel == gofeaturespb.GoFeatures_API_HYBRID | ||
} | ||
|
||
func (m *messageInfo) isOpaque() bool { | ||
return m.Message.APILevel == gofeaturespb.GoFeatures_API_OPAQUE | ||
} | ||
|
||
func opaqueNewEnumInfoHook(f *fileInfo, e *enumInfo) { | ||
if f.File.APILevel != gofeaturespb.GoFeatures_API_OPEN { | ||
e.genJSONMethod = false | ||
e.genRawDescMethod = false | ||
} | ||
} | ||
|
||
func opaqueNewMessageInfoHook(f *fileInfo, m *messageInfo) { | ||
if !m.isOpen() { | ||
m.genRawDescMethod = false | ||
m.genExtRangeMethod = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.