consulo-csharp
consulo-csharp copied to clipboard
Local ref's & readonly ref (in) support (C# 7 & 8)
- Consulo version: 2021.12 (#3101 Alpha)
- Unity version: 2021.3.6f1 (but 2020 had the problem as well, I think it is a general problem with Unity.Entities)
- OS: Kubuntu 22.04 (same on 20.04)
Hi, since I started a project with DOTS, I've been getting wrong syntax error highlighting in Entities.ForEach() lambda calls.
Code example:
Entities
.WithoutBurst()
.ForEach(
(in DynamicBuffer<EntityPrefabElement> prefabBuffer) =>
{
for (int i = 0; i < PrefabIDs.PREFAB_COUNT; i++)
{
prefabs[i] = prefabBuffer[i];
}
prefabsReady = true;
}
).Run();
Consulo marks the "in" keyword as red, with the errors "Identifier expected" and "Expected comma".
Maybe it's just some .NET framework version not matching or something, but I can't figure it out.
EDIT: Also I had some syntax error highlighting issues with a using var x = y;
+ following code using x, and generally when working with ref
s.
Hello. this constructions is not supported in C# plugin.
Hello. this constructions is not supported in C# plugin.
Oh ok, so is it because the C# plugin is not updated for the newer C#/.Net Framework version or because Unity did something special? I don't know much about this kind of construct other than it's a lambda function.
yeap. I'm not implemented this features yet
I just remembered that it could be something special from Unity, because as far as I remember, the Entities.ForEach() gets some code gen before compile time, so it might not even be completely valid C# code in the correct Framework...
using var
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/using
It's C# 8.0 feature (almost all C# 8 features not implemented yet)
Ok thanks, and for the ref
part, I'm not sure if it's also a C# 8.0 feature, but here is an example that works in Unity perfectly fine.
And if I try to access the itemDataArray by index later:
Looks like the same. Ref locals C# (C# 7 missed)
Since it's var, type inference is broken and this[] not resolved.
I will review this issues, but need time, I'm very busy with new branch.
Thanks for reporting
About in