Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Partial Fix For Source Generated Queries #55

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Arch.System.SourceGenerator/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{

foreach (var symbol in parameterSymbols)
if(symbol.Type.Name is not "Entity" || !symbol.GetAttributes().Any(data => data.AttributeClass.Name.Contains("Data"))) // Prevent entity being added to the type array

Check warning on line 22 in Arch.System.SourceGenerator/Query.cs

View workflow job for this annotation

GitHub Actions / Test (linux-release)

Dereference of a possibly null reference.
sb.AppendLine($"ref var @{symbol.Type.Name.ToLower()}FirstElement = ref chunk.GetFirst<{symbol.Type.ToDisplayString(NullableFlowState.None, SymbolDisplayFormat.FullyQualifiedFormat)}>();");

return sb;
Expand Down Expand Up @@ -260,15 +260,15 @@
Exclusive = {{exclusiveTypeArray}}
};

private {{staticModifier}} bool _{{queryMethod.MethodName}}_Initialized;
private {{staticModifier}} World? _{{queryMethod.MethodName}}_Initialized;
private {{staticModifier}} Query _{{queryMethod.MethodName}}_Query;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public {{staticModifier}} void {{queryMethod.MethodName}}Query(World world {{data}}){

if(!_{{queryMethod.MethodName}}_Initialized){
if(!ReferenceEquals(_{{queryMethod.MethodName}}_Initialized, world)) {
_{{queryMethod.MethodName}}_Query = world.Query(in {{queryMethod.MethodName}}_QueryDescription);
_{{queryMethod.MethodName}}_Initialized = true;
_{{queryMethod.MethodName}}_Initialized = world;
}

foreach(ref var chunk in _{{queryMethod.MethodName}}_Query.GetChunkIterator()){
Expand Down
Loading