Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

CS_VALUE_TYPE affects parent type if applied to inner class #559

Open
vonzepp opened this issue Sep 23, 2015 · 10 comments
Open

CS_VALUE_TYPE affects parent type if applied to inner class #559

vonzepp opened this issue Sep 23, 2015 · 10 comments

Comments

@vonzepp
Copy link
Contributor

vonzepp commented Sep 23, 2015

I expect that Record remain as 'class' in generated stub and only ItemsIterator becomes struct in code below:

class Record
{
    CS_VALUE_TYPE class ItemsIterator
    {
    };
};

But both classes becomes 'struct' in generated stub.

        public unsafe partial struct Record
        {
...
...
            internal unsafe partial struct ItemsIterator
            {

Of cource I can do it by other way

ctx.SetClassAsValueType("ItemsIterator");

but default behaviour of CS_VALUE_TYPE seems to be strange.

@tritao
Copy link
Collaborator

tritao commented Sep 23, 2015

Looking at the handling code in

if (expansions.Any(e => e.Text == Prefix + "_VALUE_TYPE"))
I think this behaviour can only be explained by a bug in the parser which makes both classes have the preprocessed entity.

Could you post a minified reproduction so we can take a look at it?

@vonzepp
Copy link
Contributor Author

vonzepp commented Sep 23, 2015

Yes, sure. But sorry I don't understand what do you mean when say

minified reproduction

? Short project containing file.h ?:

#define CS_VALUE_TYPE
class Record
{
    CS_VALUE_TYPE class ItemsIterator
    {
    };
};

@tritao
Copy link
Collaborator

tritao commented Sep 23, 2015

If that's enough to reproduce it then it's perfect, thanks.

@vonzepp
Copy link
Contributor Author

vonzepp commented Sep 23, 2015

https://www.dropbox.com/s/7wo5ruqc73j2h2q/Generator.zip?dl=0
Test project for .NET 4.6 / x64 / VS2015

> cd bin
> Generator.exe . .

First argument of generator.exe is Directory with TestFile.h, second is OutputDirectory

@tritao
Copy link
Collaborator

tritao commented Sep 23, 2015

Thanks for the effort in putting up a project. There should no need for it though, the source code above should be enough for me to reproduce it.

@genuinelucifer
Copy link
Contributor

@tritao I would like to work on this (if you haven't started this yet)... I would need some help as I had a look and couldn't find how PreprocessedEntities are actually filled in any Class.

@tritao
Copy link
Collaborator

tritao commented Sep 24, 2015

Sure Abhinav.

Preprocessed entities are handled by the parser in Parser::HandlePreprocessedEntities, https://github.com/mono/CppSharp/blob/master/src%2FCppParser%2FParser.cpp#L2603.

I am assuming the error is in the parser, but I haven't confirmed yet. You will want to test in Debug mode to be able to properly debug the native C++ code. It can be tricky to figure out issues in the native code because Clang types can be very opaque to the debugger, so ask me for help if you get stuck.

@genuinelucifer
Copy link
Contributor

genuinelucifer commented Sep 25, 2015 via email

@genuinelucifer
Copy link
Contributor

@tritao I tried debugging the code but couldn't. I also tried building C++# in debug mode but got to many clang errors and the build was never successful. Please help.

@tritao
Copy link
Collaborator

tritao commented Jan 12, 2016

@genuinelucifer Feel free to try this one again now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants