mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 04:11:05 +08:00
Fix registration of exposed fields (#1727)
This commit is contained in:
parent
04094ddf19
commit
cf3c65f0cc
@ -156,7 +156,7 @@ func (b *Bindings) AddStructToGenerateTS(packageName string, structName string,
|
|||||||
}
|
}
|
||||||
kind := field.Type.Kind()
|
kind := field.Type.Kind()
|
||||||
if kind == reflect.Struct {
|
if kind == reflect.Struct {
|
||||||
if field.PkgPath == "" {
|
if !field.IsExported() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fqname := field.Type.String()
|
fqname := field.Type.String()
|
||||||
@ -168,7 +168,7 @@ func (b *Bindings) AddStructToGenerateTS(packageName string, structName string,
|
|||||||
b.AddStructToGenerateTS(pName, sName, s)
|
b.AddStructToGenerateTS(pName, sName, s)
|
||||||
}
|
}
|
||||||
} else if kind == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct {
|
} else if kind == reflect.Ptr && field.Type.Elem().Kind() == reflect.Struct {
|
||||||
if field.PkgPath == "" {
|
if !field.IsExported() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fqname := field.Type.String()
|
fqname := field.Type.String()
|
||||||
@ -182,7 +182,6 @@ func (b *Bindings) AddStructToGenerateTS(packageName string, structName string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bindings) getAllStructNames() *slicer.StringSlicer {
|
func (b *Bindings) getAllStructNames() *slicer.StringSlicer {
|
||||||
|
@ -1,10 +1,41 @@
|
|||||||
package binding
|
package binding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/slicer"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/leaanthony/slicer"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type BindForTest struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *BindForTest) GetA() A {
|
||||||
|
return A{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type A struct {
|
||||||
|
B B `json:"B"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type B struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNestedStruct(t *testing.T) {
|
||||||
|
bind := &BindForTest{}
|
||||||
|
testBindings := NewBindings(logger.New(nil), []interface{}{bind}, []interface{}{})
|
||||||
|
|
||||||
|
namesStrSlicer := testBindings.getAllStructNames()
|
||||||
|
names := []string{}
|
||||||
|
namesStrSlicer.Each(func(s string) {
|
||||||
|
names = append(names, s)
|
||||||
|
})
|
||||||
|
assert.Contains(t, names, "binding.A")
|
||||||
|
assert.Contains(t, names, "binding.B")
|
||||||
|
}
|
||||||
|
|
||||||
func Test_goTypeToJSDocType(t *testing.T) {
|
func Test_goTypeToJSDocType(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user