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

C# pragma underneath method declaration line is rendered wrong #394

Open
makolyte opened this issue Jun 22, 2021 · 4 comments
Open

C# pragma underneath method declaration line is rendered wrong #394

makolyte opened this issue Jun 22, 2021 · 4 comments
Labels
upstream An issue related to a problem on a dependency of this plugin

Comments

@makolyte
Copy link

In the code block, add the following code with a pragma:

    public class TestClass
    {
#pragma warning disable IDE0060 // Remove unused parameter
        public void TestMethod(string param)
#pragma warning restore IDE0060 // Remove unused parameter
        {
        }
    }

Set Language = C#

This code gets rendered like this:
image
Notice the 2nd pragma (line 5) is not rendering the same as the first one (line 3).

I think it has to do with the placement of pragma. If it's underneath the method declaration line, then it renders wrong. If it's put after the method block, it's fine. I think this is a pretty minor bug, since there's a simple workaround and pragmas are pretty rare in sample code.

For example, the following is fine:

    public class TestClass
    {
#pragma warning disable IDE0060 // Remove unused parameter
        public void TestMethod(string param)
        {
        }
#pragma warning restore IDE0060 // Remove unused parameter
    }

This renders correctly:
image

@westonruter
Copy link
Owner

Does this issue happen when line numbers aren't displayed as well? It may be a parsing problem in highlight.php.

@westonruter
Copy link
Owner

Or rather, it may be a parsing problem in highlight.js. I seem to be seeing the same thing with highlight.js:

image

@makolyte
Copy link
Author

Does this issue happen when line numbers aren't displayed as well?

Yes, it happens with line numbers on or off. Same with highlighting.

@allejo allejo added the upstream An issue related to a problem on a dependency of this plugin label Jul 6, 2021
@allejo
Copy link
Collaborator

allejo commented Jul 6, 2021

This is definitely an upstream problem. hljs isn't highlighting it correctly, my guess is meta highlights aren't considered valid in between a function signature and the opening brace.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream An issue related to a problem on a dependency of this plugin
Projects
None yet
Development

No branches or pull requests

3 participants