-
Notifications
You must be signed in to change notification settings - Fork 16
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
Cannot redefine/reassign a property in the same file #100
Comments
Thanks for the detailed report! I’ll look into this tomorrow morning 🙂 |
Sorry for the delayed response (production issues at work 😂). I think I can see a solution to this problem, I just need to try it out, and will let you know when there is something to test. |
Part of the problem is that MSBuild has 3 different semantic models (or layers) that can be used to represent various aspects of the project. The language service’s heavy lifting is largely concerned with mapping between the first 2 of these models/layers: Construction (project XML) and Evaluation (evaluated property values and item groups). Part of the issue is that the mapping is not (and cannot always be) one-to-one; the construction project has 2 “Destination” property elements but the evaluation project only has one “Destination” property value. The original assumption was that we would only track the last declaration of a property in a project and use that one to link it to the actual property in the evaluation project: msbuild-project-tools-server/src/LanguageServer.SemanticModel.MSBuild/MSBuildProperty.cs Line 25 in 9f85d75
We have done a fair bit of refactoring lately and I suspect a bug has crept in somewhere that is failing to account for multiple declarations. |
…SBuild property defined and then redefined in the same project file #100
Ok, I've at least managed to validate that the language model does still correctly support properties defined and then redefined in the same project file. So it must be an upstream component in the language server. Will keep digging :) |
I'm starting to think this may actually be an issue with the targets file being picked up more than once during parsing.
|
I think 0d40200 may wind up fixing the issue. |
I still haven't gotten around to building the potential fix and checking if it solves the issue. I'll see if I can do it later today. |
Thanks! I’ve been away for the last couple of days but I’ll try to get a package built tomorrow. |
@BinToss - can you give this package msbuild-project-tools-0.6.3-redefine-property.2.zip a try? |
Give the following PropertyGroup of an imported file... <!-- ZipPublishDir.targets -->
<Project>
<PropertyGroup>
<!--
Unused value: false
Actual value: true
-->
<ANewVariable>false</ANewVariable>
<!-- Value: true -->
<ANewVariable>true</ANewVariable>
</PropertyGroup>
<Target ... ...the IntelliSense value of <!-- Condition Evaluated: true, Value: true -->
<ANewVariable Condition="$(ANewVariable)">$(ANewVariable)</ANewVariable> Given this reproducible example, the evaluation issue is not present in that package! |
Great - thanks for verifying! I’ll publish a new version as soon as I’ve addressed some minor PR feedback 🙂 |
I've published v0.6.3 of the extension to the VS gallery (it may take a couple of minutes to show up as an update in VS Code). Thanks again for contributing! |
System.ArgumentException: An item with the same key has already been added.
System.InvalidOperationException: Parent project does not have an MSBuild project.
My ZipPublishDir Target defines a
Destination
property. Then it conditionally appends to the value.MSBuild reassigns the value to the existing property–or redefines it–as expected.
msbuild-project-tools-server
cannot handle reassignments. Instead, it throwsSystem.ArgumentException
. Consequently, it cannot load any project importing a file containing this usage.When adding a key that already exists,
msbuild-project-tools-server
shouldDestination
, then the second definition's key would beDestination>1
and so on.>
character should prevent naming collisions. It cannot be used in a property name—even as>
.error caused by ZipPublishDir
ZipPublishDir
error in project importing ZipPublishDir
The text was updated successfully, but these errors were encountered: