using #ifdef inside "Windows Form Designer generated code" in C++ CLI with VS2010 - visual-studio-2010

Good afternoon,
I am having an issue trying to conditionally comment out some code sections and objects inside code that is generated by Windows Forms Designer.
If I simply comment out these objects, the designer will show no issues with the code and will display what I am working on
If I comment out with #ifdef and #endif in the code, the designer gives me
"C++ CodeDOM parser error: Line: 358, Column: 1 --- Unexpected token for a 'term' "
and will not display the UI I am working on. However the code will compile just fine without errors.
Is there a way to conditionally comment out sections of the designer code in the Form.h file?
Thanks,
-D

Do not edit designer-generated code. If your change works then it is not going to live long, wiped out when the designer re-generates the code. And the real problem, the designer code parser can only understand the kind of code it generates itself. It is not a full-blown compiler, it doesn't know beans what #ifdef might mean. Which is what the error is trying to tell you.
If you need conditional changes then you need to make them in form's constructor, after the InitializeComponent() call. You can remove or add controls and change their properties as needed.

Related

Is there a way to create code snippets in Xcode programmatically?

Is it possible to add code snippets in Xcode for autocomplete purposes without using the UI? I auto generate some data models with scripts, and wish to enable auto complete for those.
I can see the code snippets created through Xcode under ~/Library/Developer/Xcode/UserData/CodeSnippets/, but it seems like just adding a new xml file there doesn't register it with Xcode.
Oh, it seems like after I add code snippets in ~/Library/Developer/Xcode/UserData/CodeSnippets/, I have to kill/quit xcode explicitly for it to load the changes. If I just close and reopen xcode, the changes don't load.

How to restore working solution?

I was working on a C# project and everything works perfectly fine. But after I messed up with a code a little now its getting a wired error. But I can run the last working solution fine. Can I reset the code again to last working solution? If I can, what is the method to do that?
Here is the error message:
"Error 1 'Static_calc.Form2' does not contain a definition for
'Form2_Load' and no extension method 'Form2_Load' accepting a first
argument of type 'Static_calc.Form2' could be found (are you missing a
using directive or an assembly reference?)"
That sounds like you have deleted a method that your form is rely on in its designer code behind. Take a look in the designer file for Form2 for any event bindings that relate to Form2_Load and delete the line that mentions it.
You should then be able to view the form correctly in the gui and use it as before.

Dim/hide logging lines of code in Visual Studio

Is there any way to make visual studio dim or hide/show on demand logging lines of my code?
We use a lot of logging in our project and it's harder to read code like this.
I would like it to be like this, for example:
Unobtrusive Code extension worked for me for Visual Studio 2019. It dims the opacity of log lines (and comments, which I disabled - I enjoy reading my comments). He did a quick update for the nuget package, and it works great.
https://marketplace.visualstudio.com/items?itemName=niklaskallander.UnobtrusiveCode
I use this. Hoping one day they will add color customization and line selection regex options as well:
https://marketplace.visualstudio.com/items?itemName=ElmarXCV.GrayLogLines
There is no way to do this from the standard Visual Studio IDE. In order to do this you would need to define a custom extension which recognized lines like this, tagged them with a specific format and have that format be colored a lighter color in the IDE
a "hackier" way would be to wrap all logging in a preprocessor directive like
#if DEBUG
Log.Info(........)
#endif
Visual-Studio will "dim" the code inside.
and have some kind of config header where you
#define DEBUG 0
Not the prettiest but its nice if you don't want debug code compiled into your Release binary
why don't you put your section within #region tag.
E.G:
#region Put some region name here for your reference
Your Code / Comment / Whatever
#endregion

Finding T4 text template class code

T4 text templates can be used to generate not only code but also any kind of text with visual studio.
I've read blogs and tutorials about T4 and as far as I can understand, visual studio dynamically builds a class in the background, compiles and runs the code in that class to build the text output.
Is it possible to see the source code of that class?
Yes, the easiest way is to change the Custom Tool in the properties window when the template file is selected in Solution Explorer.
By default, it will be 'TextTemplatingFileGenerator'.
If you change the custom tool to 'TextTemplatingFilePreprocessor' you'll get the underlying template class instead of the template output generated into your project.
To be precise, this code won't be exactly the same as that which is run under the covers, but it will be very close.
If you need the absolute exact code, you should leave the custom tool alone, but set the debug="true" flag on your <## template #> directive. This will then leave the generated code sitting around in a random named '.cs' or 'vb' file in your %TEMP% directory. Just sort the directory by time and it should be up at the top.

shadow message in Wolfram Workbench 2.0

I am writing documentation for a package with WB 2.0.
Very often, when I create links or insert cells using the documentation tools palette, I get the following message:
GlobalStyleNames::shdw: Symbol StyleNames appears in multiple contexts {Global,System}; definitions in context Global may shadow or be shadowed by other definitions. >>
This message appears even after I start a new session of Workbench - Mathematica.
Except for this, everything else seems to work fine. The documentation pages seem ok, although I have not yet made a "Build". Links, for ex, work as expected.
Can you explain why I get this message and how to fix it?
Should I expect problems at the Build stage?
The only "hint" I can give (maybe irrelevant) is that the first time I created the symbol pages (automatically from the usage messages), WB got "confused" somehow and included the pages for the Numerical sample package which I downloaded from the Wolfram Workbench web site. I erased these symbol pages and eliminated any link/connection/extension relating to this Numerical package and since then everything seems ok, except for the above message.
I just experimented a little further with this problem and this is exactly what happens:
Start WB 2.0
In package explorer, doubleclick on a .nb file so that MMA is automatically started as default editor (I use the CardDeck.nb file in the CardDeck sample package found on Workbench site)
When in MMA, open the DocumentationTools palette
Click on the sample tutorial page button (or most other buttons for that matter)
Bang! I get the message:
GlobalStyleNames::shdw: Symbol StyleNames appears in multiple contexts {Global,System}; definitions in context Global may shadow or be shadowed by other definitions. >>
in the message window.
So it seems that this problem is not related specifically to my package files, but is somehow linked to the DocumentationTools palette.
Does anybody else have this problem?
Is it a corrupted installation?
Thank you for any help
You could try switching off the automatic source loading for specific notebooks via Properties, Notebook Properties.

Resources