Skip to content

generate-helper-types generates invalid code when multi-file is not specified #657

@RikkiGibson

Description

@RikkiGibson

For an rsp file like:

--config
generate-helper-types
--file
include/samplerate.h
--methodClassName
LibSampleRate
--namespace
LibSampleRateDotNet
--output
lib/file.cs
-l
samplerate.dll

Code like the following is generated. There are extra using directives etc between the helper types, so it won't compile. Valid code is generated when the multi-file option is also used.

namespace LibSampleRateDotNet
{
    public partial struct SRC_STATE_tag
    {
    }

    public unsafe partial struct SRC_DATA
    {
        [NativeTypeName("const float *")]
        public float* data_in;

        public float* data_out;

        [NativeTypeName("long")]
        public int input_frames;

        [NativeTypeName("long")]
        public int output_frames;

        [NativeTypeName("long")]
        public int input_frames_used;

        [NativeTypeName("long")]
        public int output_frames_gen;

        public int end_of_input;

        public double src_ratio;
    }
using System;
using System.Diagnostics;

namespace LibSampleRateDotNet
{
    /// <summary>Defines the type of a member as it was used in the native signature.</summary>
    [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)]
    [Conditional("DEBUG")]
    internal sealed partial class NativeTypeNameAttribute : Attribute
    {
        private readonly string _name;

        /// <summary>Initializes a new instance of the <see cref="NativeTypeNameAttribute" /> class.</summary>
        /// <param name="name">The name of the type that was used in the native signature.</param>
        public NativeTypeNameAttribute(string name)
        {
            _name = name;
        }

        /// <summary>Gets the name of the type that was used in the native signature.</summary>
        public string Name => _name;
    }
}
using System;
using System.Diagnostics;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions