Adding code snippets in TwinCAT3 TcXaeShell - twincat

How can I add code snippets in TcXaeShell enviroment for TwinCAT3 ?. Insert Code snippet command doesn't seem to work (Ctrl+K, Ctrl+X).

Related

Is there any way to find the C# code that is created from XAML with Xamarin?

Given some Xaml like this:
<headingView:HeadingView
x:Class="Test.Views.Decks.DeckBase.DeckMgmt.DeckMgmtPage2"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:headingView="clr-namespace:Test.Templates.Pages.HeadingView;assembly=Test"
xmlns:t="clr-namespace:Test.Templates"
BackIconVisible="True"
PageTitle="Mgmt">
<t:Stack>
<t:ContentFrame Heading="Reset">
<t:LinkGrid TapCommand="{Binding ResetDeckCmd}" Text1="Reset" />
</t:ContentFrame>
<t:ContentFrame Heading="Sort">
<t:LinkGrid Text1="Sort" />
</t:ContentFrame>
</t:Stack>
</headingView:HeadingView>
I don't need help in changing this to C# but I would like to know if there is any place or way I can find out the intermediate C# that is created?
Viewing the actual code generated by the compiler is tricky (I tried for a couple of hours but I could not find a way to directly view the code) - but it is possible to view the source code itself.
First of all - download .NET reflector and the appropriate Visual Studio extension.
https://visualstudio.microsoft.com/vs/preview/
Now we need to find the method that we want to decompile.
The method Xamarin.Forms.Xaml.Extensions.LoadFromXaml() is found in your page's xaml.g.cs file. According to Microsoft:
When Visual Studio builds a project containing a XAML file, it [the method] parses the XAML file to generate a C# code file (for example, MainPage.xaml.g.cs) that contains the definition of the InitializeComponent method:
The method in this case is the LoadFromXaml() method.
Now add a breakpoint like so:
Press F12 until you reach the following:
You will reach the 'Load' method:
You will see something like this:
From here - you can browse the rest of the XamlLoader class's source code:
Very interesting, isn't it? This is the closest thing to a solution that I got to.
I've just shared it as an image as I don't think it would be appropriate to share the full code as a code snippet.
It's not exactly what you're looking for - but I still hope this helped answer your question either way.

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.

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

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.

How to add a link to the full source code with sphinx-doc?

I wrote a documentation with python-sphinx and I use the sphinx.ext.viewcode extension in order to link part of the documentation to the corresponding source code.
How can I add a link to that page but without hilighting something ?

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

Resources