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

Using statement ordering and conditional compilation #1291

Open
Rudomitori opened this issue Jun 12, 2024 · 1 comment
Open

Using statement ordering and conditional compilation #1291

Rudomitori opened this issue Jun 12, 2024 · 1 comment
Labels

Comments

@Rudomitori
Copy link
Contributor

Ordering of using statement incorrectly handles conditional compilation preprocessor directives

Input:
The code is from csharpier-repos

#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif

#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MSX = MonoSecurity::Mono.Security.X509;
using MonoSecurity::Mono.Security.X509.Extensions;
#else
using Mono.Security.Interface;
using MSX = Mono.Security.X509;
using Mono.Security.X509.Extensions;
#endif

using System;
using System.Net;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Net.Configuration;
using System.Text.RegularExpressions;
using System.Security.Cryptography.X509Certificates;

using System.Globalization;
using System.Net.Security;
using System.Diagnostics;

Output:

#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif

#else
using Mono.Security.Interface;
#endif

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Configuration;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;
using Mono.Security.X509.Extensions;
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
using MonoSecurity::Mono.Security.X509.Extensions;
using MSX = MonoSecurity::Mono.Security.X509;
using MSX = Mono.Security.X509;

Tested in the playground for the version 0.28.1

@belav
Copy link
Owner

belav commented Jun 16, 2024

If I recall correctly there were a couple edge cases like this from csharpier-repos. Fixing them didn't seem straightforward and some of the official analzyers don't deal well with conditional compilation so I let them slide.

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

No branches or pull requests

2 participants