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 not worked in compilation #86

Closed
itn3000 opened this issue Oct 12, 2018 · 2 comments
Closed

DefineConstants not worked in compilation #86

itn3000 opened this issue Oct 12, 2018 · 2 comments
Labels
General Enhancement New feature or request

Comments

@itn3000
Copy link
Contributor

itn3000 commented Oct 12, 2018

Environment

  • dotnet sdk 2.1.402
  • Buildalyzer: 2.1.0
  • windows8.1 x64

Steps to reproduce

  1. unpack buildalyzertest.constants.zip
  2. move "buildalyzertest.constants/buildalyzertest.constants"
  3. run dotnet run

"buildalyzertest.constants/buildalyzertest.constants" does

  1. get project instance of sandboxproject
  2. get workspace by ProjectAnalyzerExtensions.GetWorkspace()
  3. enumerate class names

Expected Result

ns=sandboxproject.X1, X1
ns=sandboxproject.X3, X3
ns=sandboxproject.Program, Program
Hello World!

it means sandboxproject.X1(surrounded by DEF1 symbol) is included in Compilation.Assembly.

Actual Result

ns=sandboxproject.X3, X3
ns=sandboxproject.Program, Program
Hello World!

sandboxproject.X1 is not included in Compilation.Assembly.
DEF1 seems to be not defined in compilation.

Additionally, do dotnet build in sandboxproject by hand and analyze output assembly by dnSpy,
sandboxproject.X1 is included in symbols.

@daveaglick daveaglick added the General Enhancement New feature or request label Nov 1, 2018
@daveaglick
Copy link
Collaborator

I can see where the problem is here. The constant will get defined correctly during the MSBuild pass when we build the project(s) and get the resulting project files, but then in .GetWorkspace() it passes those project files along with some other rudimentary information to Roslyn but doesn't pass the defined constants.

To get this to work I'll need to make sure any build constants get passed to Roslyn. This is tricky because I can't just pull those right out of the project file - they've got to come from the result of the build since they could get redefined or even based on other constants. I'll start looking into this.

@daveaglick
Copy link
Collaborator

This is now resolved and will ship with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants