In our last post we started to dig into how the Compile target is used by Visual Studio at design time, and the details around the in-process compiler. When Rajeev was talking about the in-process vs. out-of-process compiler during the talk I must admit I started to doze off a bit. I’m much more of a UI guy. That’s why I got so jazzed about how MSBuild plays a key role in Intellisense.
As mentioned in the previous post, when a project file is opened by Visual Studio, the Compile target is called to get a compile going and populate the Intellisense dropdown. The super cool part was Rajeev’s very visual demonstration of the relationship between MSBuild and Intellisense.
To see the demo for yourself, try the following:
<CreateProperty Condition="Exists('c:\foo.txt')" Value="$(DefineConstants);FOO_TXT_EXISTS">
<Output TaskParameter="Value" PropertyName="DefineConstants"/>
MyBoolean doesn’t show up! Why on earth not? Well, because the FOO_TXT_EXISTS define is only added to the DefineConstants property if the foo.txt file exists in the root of the c: drive. Since Visual Studio calls the MSBuild Compile task on project load to initialize Intellisense, and myBoolean is wrapped in a #if that isn’t set by the project file, myBoolean doesn’t exist after compilation.
Now let’s see what happens when the file exists. Create an empty file called “foo.txt” in the root of your c: drive, close your project, then open it again. Try typing “this.myBoolean” again in the class. Voila! Now it shows up in intellisense.
Very, very cool. Nice demo, Rajeev!
[ Author: Neil Enns ]