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

Issues with nullable value types #8

Open
N-b-dy opened this issue Feb 13, 2022 · 5 comments
Open

Issues with nullable value types #8

N-b-dy opened this issue Feb 13, 2022 · 5 comments

Comments

@N-b-dy
Copy link

N-b-dy commented Feb 13, 2022

Hi rogerbarton,

first of all thanks for you great job improving/providing a Sphinx domain for C#. I'm using it currently with DoxyGen and Breathe in a project and getting some issues with the nullable value types of C# 8.0 (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types).

This is an example C# code for describing the problem.

    public class ExampleClass
    {
        /// <summary>
        /// Constructor of the class.
        /// </summary>
        public ExampleClass()
        {
        }

        /// <summary>
        /// A nullable bool value.
        /// </summary>
        public bool? BNullableBool { get; set; }

        /// <summary>
        /// A nullable int value.
        /// </summary>
        public int? NNullableInt { get; set; }

        /// <summary>
        /// A nullable function.
        /// </summary>
        /// <param name="bValue">A nullable bool.</param>
        /// <returns>A nullable int.</returns>
        public int? FooBar(bool? bValue)
        {
            return null;
        }
    }

In Sphinx I'm using the following Breathe directive to create the HTML output:

    .. doxygenclass:: WpfApp1::Models::ExampleClass
        :members:

During the build I'm getting the following warnings:

WARNING: Method signature invalid: int? FooBar (bool? bValue)
WARNING: Definition list ends without a blank line; unexpected unindent.

And the output looks like this:

Breathe

The types of the properties are not getting parsed properly and also the "highlighting" of them differs from the other stuff in case of a method.

I'm not totally sure if this issue is completly solvable by this domain, but I hope you can help me.

@rogerbarton
Copy link
Owner

I will have a look at this tomorrow, but I think it should work will nullables (or I can hopefully make it work easily).

Thanks for the detailed description and example. This helps a lot!

@rogerbarton
Copy link
Owner

Ok the regex was not quite correct, but I think it should work now. I've added your example class as a test and it works for me.
Please pip install again.
Does this solve your problem?

@N-b-dy
Copy link
Author

N-b-dy commented Feb 15, 2022

Yes, the ExampleClass looks fine now, thanks for that!

ExampleClass

I just tried it also with an extension class in combination with the nullable variables. The same warnings are coming up for that one and the display doesn't fit yet either.

    /// <summary>
    /// A static extension class.
    /// </summary>
    public static class FooBarExtension
    {
        /// <summary>
        /// Just an extension method.
        /// </summary>
        /// <param name="nullableBool">A nullable bool.</param>
        /// <returns>A nullable int.</returns>
        public static int? Foo(this bool? nullableBool)
        {
            return null;
        }

        /// <summary>
        /// Another extension method.
        /// </summary>
        /// <param name="normalBool">A normal bool.</param>
        /// <returns>A normal int.</returns>
        public static int Bar(this bool normalBool)
        {
            if (normalBool)
                return 1;

            return 0;
        }
    }

ExtensionClass

Can you take a look at that one as well?

@rogerbarton
Copy link
Owner

I will have a look at it over the next few days.
Although it looks more complicated because the ? is no longer at the end of the type, maybe because of the doxygen output.

@rogerbarton
Copy link
Owner

rogerbarton commented Feb 16, 2022

It seems to only be an issue when the function is static and returns a nullable. Pointers work fine strangely:
image

Somehow the input to the package already has the ? before the type, despite the doxyen xml having the correct ordering.
Not sure why this is happening. Unfortunately, I don't have much time to look into this, so it will not be supported at the moment.

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

2 participants