Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 6b5fd78

Browse files
authored
Fixing name clashes between packages and component / type names (#903)
* updating templates to fix name clashes * pr feedback * all the generated code * PR feedback
1 parent 1e4a762 commit 6b5fd78

File tree

110 files changed

+1033
-1017
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1033
-1017
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
- Fixed an issue where player creation requests could retry infinitely without logging failure.
3535
- Fixed an issue where if you called `RedirectedProcess.Command(...)` in a non-main thread, it would throw an exception.
36+
- Fixed an issue where having the same name for a schema package and a schema component would lead to generating invalid code.
3637

3738
### Internal
3839

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package name;
2+
3+
type Test {
4+
float color = 1;
5+
}
6+
7+
component Name
8+
{
9+
id = 200;
10+
float name = 1;
11+
}

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKey.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public Snapshot(global::System.Collections.Generic.Dictionary<BlittableBool,stri
421421

422422
public static class Serialization
423423
{
424-
public static void SerializeComponent(Improbable.Gdk.Tests.ExhaustiveMapKey.Component component, global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
424+
public static void SerializeComponent(global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component component, global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
425425
{
426426
{
427427
foreach (var keyValuePair in component.Field1)
@@ -587,7 +587,7 @@ public static void SerializeComponent(Improbable.Gdk.Tests.ExhaustiveMapKey.Comp
587587
}
588588
}
589589

590-
public static void SerializeUpdate(Improbable.Gdk.Tests.ExhaustiveMapKey.Component component, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
590+
public static void SerializeUpdate(global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component component, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
591591
{
592592
var obj = updateObj.GetFields();
593593
{
@@ -916,7 +916,7 @@ public static void SerializeUpdate(Improbable.Gdk.Tests.ExhaustiveMapKey.Compone
916916
}
917917
}
918918

919-
public static void SerializeUpdate(Improbable.Gdk.Tests.ExhaustiveMapKey.Update update, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
919+
public static void SerializeUpdate(global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update update, global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
920920
{
921921
var obj = updateObj.GetFields();
922922
{
@@ -1245,7 +1245,7 @@ public static void SerializeUpdate(Improbable.Gdk.Tests.ExhaustiveMapKey.Update
12451245
}
12461246
}
12471247

1248-
public static void SerializeSnapshot(Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot snapshot, global::Improbable.Worker.CInterop.SchemaObject obj)
1248+
public static void SerializeSnapshot(global::Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot snapshot, global::Improbable.Worker.CInterop.SchemaObject obj)
12491249
{
12501250
{
12511251
foreach (var keyValuePair in snapshot.Field1)
@@ -1411,9 +1411,9 @@ public static void SerializeSnapshot(Improbable.Gdk.Tests.ExhaustiveMapKey.Snaps
14111411
}
14121412
}
14131413

1414-
public static Improbable.Gdk.Tests.ExhaustiveMapKey.Component Deserialize(global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
1414+
public static global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component Deserialize(global::Improbable.Worker.CInterop.SchemaObject obj, global::Unity.Entities.World world)
14151415
{
1416-
var component = new Improbable.Gdk.Tests.ExhaustiveMapKey.Component();
1416+
var component = new global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component();
14171417

14181418
component.field1Handle = Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.Field1Provider.Allocate(world);
14191419
{
@@ -1670,9 +1670,9 @@ public static Improbable.Gdk.Tests.ExhaustiveMapKey.Component Deserialize(global
16701670
return component;
16711671
}
16721672

1673-
public static Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
1673+
public static global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj)
16741674
{
1675-
var update = new Improbable.Gdk.Tests.ExhaustiveMapKey.Update();
1675+
var update = new global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update();
16761676
var obj = updateObj.GetFields();
16771677

16781678
var clearedFields = updateObj.GetClearedFields();
@@ -2112,9 +2112,9 @@ public static Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(glo
21122112
return update;
21132113
}
21142114

2115-
public static Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(global::Improbable.Worker.CInterop.SchemaComponentData data)
2115+
public static global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(global::Improbable.Worker.CInterop.SchemaComponentData data)
21162116
{
2117-
var update = new Improbable.Gdk.Tests.ExhaustiveMapKey.Update();
2117+
var update = new global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update();
21182118
var obj = data.GetFields();
21192119

21202120
{
@@ -2336,9 +2336,9 @@ public static Improbable.Gdk.Tests.ExhaustiveMapKey.Update DeserializeUpdate(glo
23362336
return update;
23372337
}
23382338

2339-
public static Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot DeserializeSnapshot(global::Improbable.Worker.CInterop.SchemaObject obj)
2339+
public static global::Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot DeserializeSnapshot(global::Improbable.Worker.CInterop.SchemaObject obj)
23402340
{
2341-
var component = new Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot();
2341+
var component = new global::Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot();
23422342

23432343
{
23442344
component.Field1 = new global::System.Collections.Generic.Dictionary<BlittableBool,string>();
@@ -2595,7 +2595,7 @@ public static Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot DeserializeSnapshot
25952595
return component;
25962596
}
25972597

2598-
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref Improbable.Gdk.Tests.ExhaustiveMapKey.Component component)
2598+
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component component)
25992599
{
26002600
var obj = updateObj.GetFields();
26012601

@@ -3035,7 +3035,7 @@ public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponen
30353035
}
30363036
}
30373037

3038-
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot snapshot)
3038+
public static void ApplyUpdate(global::Improbable.Worker.CInterop.SchemaComponentUpdate updateObj, ref global::Improbable.Gdk.Tests.ExhaustiveMapKey.Snapshot snapshot)
30393039
{
30403040
var obj = updateObj.GetFields();
30413041

@@ -3505,7 +3505,7 @@ public struct ReceivedUpdates : IComponentData
35053505
internal uint handle;
35063506
public global::System.Collections.Generic.List<Update> Updates
35073507
{
3508-
get => Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.UpdatesProvider.Get(handle);
3508+
get => global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.UpdatesProvider.Get(handle);
35093509
}
35103510
}
35113511

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyComponentDiffDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public uint GetComponentId()
1818

1919
public void AddUpdateToDiff(ComponentUpdateOp op, ViewDiff diff, uint updateId)
2020
{
21-
var update = Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.DeserializeUpdate(op.Update.SchemaData.Value);
21+
var update = global::Improbable.Gdk.Tests.ExhaustiveMapKey.Serialization.DeserializeUpdate(op.Update.SchemaData.Value);
2222
diff.AddComponentUpdate(update, op.EntityId, op.Update.ComponentId, updateId);
2323
}
2424

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyEcsViewManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void AddComponent(EntityId entityId)
101101
{
102102
workerSystem.TryGetEntity(entityId, out var entity);
103103

104-
var component = new Improbable.Gdk.Tests.ExhaustiveMapKey.Component();
104+
var component = new global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component();
105105

106106
component.field1Handle = Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.Field1Provider.Allocate(world);
107107
component.field2Handle = Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.Field2Provider.Allocate(world);
@@ -131,7 +131,7 @@ private void RemoveComponent(EntityId entityId)
131131
workerSystem.TryGetEntity(entityId, out var entity);
132132
entityManager.RemoveComponent<ComponentAuthority>(entity);
133133

134-
var data = entityManager.GetComponentData<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity);
134+
var data = entityManager.GetComponentData<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity);
135135
ExhaustiveMapKey.ReferenceTypeProviders.Field1Provider.Free(data.field1Handle);
136136
ExhaustiveMapKey.ReferenceTypeProviders.Field2Provider.Free(data.field2Handle);
137137
ExhaustiveMapKey.ReferenceTypeProviders.Field3Provider.Free(data.field3Handle);
@@ -151,7 +151,7 @@ private void RemoveComponent(EntityId entityId)
151151
ExhaustiveMapKey.ReferenceTypeProviders.Field17Provider.Free(data.field17Handle);
152152
ExhaustiveMapKey.ReferenceTypeProviders.Field18Provider.Free(data.field18Handle);
153153

154-
entityManager.RemoveComponent<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity);
154+
entityManager.RemoveComponent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>(entity);
155155
}
156156

157157
private void ApplyUpdate(in ComponentUpdateReceived<Update> update, ComponentDataFromEntity<Component> dataFromEntity)

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyProviders.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static class ReferenceTypeProviders
1515
{
1616
public static class UpdatesProvider
1717
{
18-
private static readonly Dictionary<uint, List<Improbable.Gdk.Tests.ExhaustiveMapKey.Update>> Storage = new Dictionary<uint, List<Improbable.Gdk.Tests.ExhaustiveMapKey.Update>>();
18+
private static readonly Dictionary<uint, List<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update>> Storage = new Dictionary<uint, List<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update>>();
1919
private static readonly Dictionary<uint, global::Unity.Entities.World> WorldMapping = new Dictionary<uint, Unity.Entities.World>();
2020

2121
private static uint nextHandle = 0;
@@ -24,13 +24,13 @@ public static uint Allocate(global::Unity.Entities.World world)
2424
{
2525
var handle = GetNextHandle();
2626

27-
Storage.Add(handle, default(List<Improbable.Gdk.Tests.ExhaustiveMapKey.Update>));
27+
Storage.Add(handle, default(List<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update>));
2828
WorldMapping.Add(handle, world);
2929

3030
return handle;
3131
}
3232

33-
public static List<Improbable.Gdk.Tests.ExhaustiveMapKey.Update> Get(uint handle)
33+
public static List<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update> Get(uint handle)
3434
{
3535
if (!Storage.TryGetValue(handle, out var value))
3636
{
@@ -40,7 +40,7 @@ public static uint Allocate(global::Unity.Entities.World world)
4040
return value;
4141
}
4242

43-
public static void Set(uint handle, List<Improbable.Gdk.Tests.ExhaustiveMapKey.Update> value)
43+
public static void Set(uint handle, List<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Update> value)
4444
{
4545
if (!Storage.ContainsKey(handle))
4646
{

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveMapKeyReactiveComponents.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
2828
}
2929

3030
List<Update> updates;
31-
if (entityManager.HasComponent<Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity))
31+
if (entityManager.HasComponent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity))
3232
{
33-
updates = entityManager.GetComponentData<Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity).Updates;
33+
updates = entityManager.GetComponentData<global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReceivedUpdates>(entity).Updates;
3434
}
3535
else
3636
{
@@ -49,7 +49,7 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
4949

5050
public void Clean(World world)
5151
{
52-
ExhaustiveMapKey.ReferenceTypeProviders.UpdatesProvider.CleanDataInWorld(world);
52+
global::Improbable.Gdk.Tests.ExhaustiveMapKey.ReferenceTypeProviders.UpdatesProvider.CleanDataInWorld(world);
5353
}
5454
}
5555

@@ -158,7 +158,7 @@ public void PopulateReactiveComponents(ComponentUpdateSystem updateSystem, Entit
158158
{
159159
workerSystem.TryGetEntity(entityId, out var entity);
160160
entityManager.AddComponent(entity,
161-
ComponentType.Create<NotAuthoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
161+
ComponentType.Create<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
162162
}
163163

164164
for (int i = 0; i < authorityChanges.Count; ++i)
@@ -182,39 +182,39 @@ private void ApplyAuthorityChange(Unity.Entities.Entity entity, Authority author
182182
switch (authority)
183183
{
184184
case Authority.Authoritative:
185-
if (!entityManager.HasComponent<NotAuthoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
185+
if (!entityManager.HasComponent<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
186186
{
187187
LogInvalidAuthorityTransition(Authority.Authoritative, Authority.NotAuthoritative, entityId);
188188
return;
189189
}
190190

191-
entityManager.RemoveComponent<NotAuthoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
192-
entityManager.AddComponent(entity, ComponentType.Create<Authoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
191+
entityManager.RemoveComponent<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
192+
entityManager.AddComponent(entity, ComponentType.Create<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
193193

194194
break;
195195
case Authority.AuthorityLossImminent:
196-
if (!entityManager.HasComponent<Authoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
196+
if (!entityManager.HasComponent<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
197197
{
198198
LogInvalidAuthorityTransition(Authority.AuthorityLossImminent, Authority.Authoritative, entityId);
199199
return;
200200
}
201201

202-
entityManager.AddComponent(entity, ComponentType.Create<AuthorityLossImminent<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
202+
entityManager.AddComponent(entity, ComponentType.Create<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
203203
break;
204204
case Authority.NotAuthoritative:
205-
if (!entityManager.HasComponent<Authoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
205+
if (!entityManager.HasComponent<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
206206
{
207207
LogInvalidAuthorityTransition(Authority.NotAuthoritative, Authority.Authoritative, entityId);
208208
return;
209209
}
210210

211-
if (entityManager.HasComponent<AuthorityLossImminent<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
211+
if (entityManager.HasComponent<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity))
212212
{
213-
entityManager.RemoveComponent<AuthorityLossImminent<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
213+
entityManager.RemoveComponent<AuthorityLossImminent<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
214214
}
215215

216-
entityManager.RemoveComponent<Authoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
217-
entityManager.AddComponent(entity, ComponentType.Create<NotAuthoritative<Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
216+
entityManager.RemoveComponent<Authoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>(entity);
217+
entityManager.AddComponent(entity, ComponentType.Create<NotAuthoritative<global::Improbable.Gdk.Tests.ExhaustiveMapKey.Component>>());
218218
break;
219219
}
220220
}
@@ -227,7 +227,7 @@ private void LogInvalidAuthorityTransition(Authority newAuthority, Authority exp
227227
// .WithField(LoggingUtils.EntityId, entityId.Id)
228228
// .WithField("New Authority", newAuthority)
229229
// .WithField("Expected Old Authority", expectedOldAuthority)
230-
// .WithField("Component", "Improbable.Gdk.Tests.ExhaustiveMapKey")
230+
// .WithField("Component", "global::Improbable.Gdk.Tests.ExhaustiveMapKey")
231231
// );
232232
}
233233
}

0 commit comments

Comments
 (0)