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

DefineConstants in csproj just ignored #3749

Closed
rlanhellas opened this issue Apr 28, 2020 · 5 comments
Closed

DefineConstants in csproj just ignored #3749

rlanhellas opened this issue Apr 28, 2020 · 5 comments

Comments

@rlanhellas
Copy link

Environment data

.NET Core SDK (reflecting any global.json):
Version: 2.1.607
Commit: cad4fbe2d5

Runtime Environment:
OS Name: fedora
OS Version: 31
OS Platform: Linux
RID: fedora.31-x64
Base Path: /usr/share/dotnet/sdk/2.1.607/

Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8

.NET Core SDKs installed:
2.1.607 [/usr/share/dotnet/sdk]
3.1.201 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Steps to reproduce

Add ENABLE_FIDDLER in ".csproj" file of IntegrationTests. This is my csproj:

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <IsPackable>false</IsPackable>
    <DefineConstants>ENABLE_FIDDLER</DefineConstants>
  </PropertyGroup>

And my peace of code:

#if ENABLE_FIDDLER
        var httpClient = _httpClientFactory.CreateClient("ProxiedClient");
#else
        var httpClient = _httpClientFactory.CreateClient();
#endif

Expected behavior

ENABLE_FIDDLER constant should be set to enter in IF condition.

Actual behavior

ENABLE_FIDDLER constant isn't set and always my peace of code is ignored.

@JoeRobich
Copy link
Member

@rlanhellas Sorry this is causing issues. Looks like this might be fixed with OmniSharp/omnisharp-roslyn#1774

@rlanhellas
Copy link
Author

Thanks, I will watch this PR.

@filipw
Copy link
Contributor

filipw commented Apr 30, 2020

I am not sure what the bug here is. OmniSharp/omnisharp-roslyn#1774 doesn't have anything to do with this becuase it deals with compilation options and these here are parse options which are already respected and updated on every csproj change

Have a look at this. Imagine I have <DefineConstants>FOO</DefineConstants> in my csproj.

Screen Shot 2020-04-30 at 14 18 20

notice how Foo() shows 1 reference?

As soon as I remove <DefineConstants>FOO</DefineConstants>:

Screen Shot 2020-04-30 at 14 20 02

notice how Foo() is now unreachable? (no code lens).
The only thing not supported at the moment is "fading out" like VS.

@SirIntruder
Copy link

Filip is right, I can also confirm changes to DefineConstants are correctly applied already. Turns out they were part of ParseOptions, not CompilationOptions.

One thing that confused me while I was testing, changes to baseline <DefineConstants> are ignored if you, by any chance, have separate <DefineConstants> defined in Release/Debug configurations in .csproj file. That's just normal VS/MSBuild behaviour, not a bug.

@JoeRobich
Copy link
Member

Closing due to lack of activity.

@JoeRobich JoeRobich closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants