Skip to content

Combining #if SYNC_ONLY with if(...) or using(...) ends up with missing code #45

@persn

Description

@persn

I don't know how well supported #if SYNC_ONLY #else "endif is supposed to be, but if I try doing the following it works perfectly like expected

[Zomp.SyncMethodGenerator.CreateSyncVersion]
public static async Task Foo2Async()
{
#if SYNC_ONLY
    _ = true;
#else
    _ = true;
#endif
    await Task.Delay(100).ConfigureAwait(false);
}

However if I do something that has () like if or using inside the directives it'll lose all code after #endif

[Zomp.SyncMethodGenerator.CreateSyncVersion]
public static async Task FooAsync()
{
#if SYNC_ONLY
    if (true)
#else
    if (true)
#endif
        await Task.Delay(100).ConfigureAwait(false);
}

Because the generated code ends up like this

public static void Foo()
{
    if (true)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions