File tree Expand file tree Collapse file tree 4 files changed +32
-3
lines changed
Bootsharp.Publish.Test/Pack Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,27 @@ public void DifferentSpacesWithSameRootAssignedUnderSameObject ()
169
169
""" ) ;
170
170
}
171
171
172
+ [ Fact ]
173
+ public void DifferentSpacesStartingEquallyAreNotAssignedToSameObject ( )
174
+ {
175
+ AddAssembly (
176
+ WithClass ( "Foo" , "[JSInvokable] public static void Method () { }" ) ,
177
+ WithClass ( "FooBar.Baz" , "[JSInvokable] public static void Method () { }" )
178
+ ) ;
179
+ Execute ( ) ;
180
+ Contains (
181
+ """
182
+ export const Foo = {
183
+ method: () => getExports().Foo_MockClass.Method()
184
+ };
185
+ export const FooBar = {
186
+ Baz: {
187
+ method: () => getExports().FooBar_Baz_MockClass.Method()
188
+ }
189
+ };
190
+ """ ) ;
191
+ }
192
+
172
193
[ Fact ]
173
194
public void BindingsFromMultipleSpacesAssignedToRespectiveObjects ( )
174
195
{
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ public string Build (Type type)
25
25
return space ;
26
26
}
27
27
28
- private IEnumerable < CustomAttributeData > CollectAttributes ( System . Reflection . Assembly assembly )
28
+ private IEnumerable < CustomAttributeData > CollectAttributes ( Assembly assembly )
29
29
{
30
30
return assembly . CustomAttributes . Where ( a => a . AttributeType . Name == attributeName ) ;
31
31
}
Original file line number Diff line number Diff line change @@ -69,7 +69,8 @@ private bool ShouldCloseNamespace ()
69
69
70
70
private void CloseNamespace ( )
71
71
{
72
- var target = nextBinding is null ? 0 : nextBinding . Namespace . Count ( c => c == '.' ) ;
72
+ var target = ( nextBinding is null || GetRoot ( nextBinding ) != GetRoot ( binding ) ) ? 0
73
+ : nextBinding . Namespace . Count ( c => c == '.' ) ;
73
74
for ( ; level >= target ; level -- )
74
75
if ( level == 0 ) builder . Append ( "\n };" ) ;
75
76
else builder . Append ( $ "\n { Pad ( level ) } }}") ;
@@ -132,6 +133,13 @@ private void EmitEnum (Type @enum)
132
133
builder . Append ( $ "{ Comma ( ) } \n { Pad ( level + 1 ) } { @enum . Name } : {{ { fields } }}") ;
133
134
}
134
135
136
+ private string GetRoot ( Binding binding )
137
+ {
138
+ var firstDotIdx = binding . Namespace . IndexOf ( '.' ) ;
139
+ if ( firstDotIdx < 0 ) return binding . Namespace ;
140
+ return binding . Namespace [ ..firstDotIdx ] ;
141
+ }
142
+
135
143
private string Pad ( int level ) => new ( ' ' , level * 4 ) ;
136
144
private string Comma ( ) => builder [ ^ 1 ] == '{' ? "" : "," ;
137
145
private bool ShouldWait ( MethodMeta method ) =>
Original file line number Diff line number Diff line change 1
1
<Project >
2
2
<PropertyGroup >
3
- <Version >0.1.1 </Version >
3
+ <Version >0.1.2 </Version >
4
4
<Authors >Elringus</Authors >
5
5
<PackageTags >javascript typescript ts js wasm node deno bun interop codegen</PackageTags >
6
6
<PackageProjectUrl >https://bootsharp.com</PackageProjectUrl >
You can’t perform that action at this time.
0 commit comments