Skip to content

Invalid C# codegen for C adjacent string literals. #694

@mmkiwi

Description

@mmkiwi

I'm getting some invalid C# code gen when there are adjacent strings in the C code. The header file i'm trying to generate is coming from this header file.

// c header file

#define CPL_WARN_DEPRECATED(x) __attribute__((deprecated(x)))

int CPL_DLL CPL_STDCALL GDALGetDataTypeSize(GDALDataType)
    CPL_WARN_DEPRECATED("Use GDALGetDataTypeSizeBits() or "
                        "GDALGetDataTypeSizeBytes() * 8 instead");
// Generated C# Code
[DllImport("gdal", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[Obsolete("Use GDALGetDataTypeSizeBits() or "  // <--- Syntax Error, ',' expected
          "GDALGetDataTypeSizeBytes() * 8 instead")]
public static extern int GDALGetDataTypeSize(GDALDataType param0);

I can't override this method with --with-attributes since that just adds a duplicate attribute, and I don't see a config option to exclude the [Obsolete] (though I really would like to keep all the other methods' attributes)

For now I just edited the header file to remove the line break, but ideally these strings would get concatenated or a + sign would be emitted in C# so that I don't have issues next time I sync with upstream.

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