Insert a line of comment in Visual Studio - printing

I'm looking for a shortcut in Visual C# Studio 2012 ( if it exists ), that will insert a line of comment like so:
/******************************************************************************/
These make the code more readable for me. What I want to achieve is to separate blocks of code which are written to achieve different things. Let's say:
/****************************************************************************/
{
// block that does something
}
/****************************************************************************/
{
// block that does something else
}
/****************************************************************************/
What I don't want to do is press and hold "*" until it prints the right number of stars.
Don't want to copy paste such comments.
Any hints?
--------------EDIT--------------
Solution found:
Steve Fenton - creating a snippet, tyvm ;)

You can create custom code snippets in Visual Studio that will speed this up, but please discuss this to ensure everyone working on the code is happy with the convention. In a modern IDE this kind of commenting is really noisy and many people don't want the code littered with this kind of delimiter.
You import snippet files using Tools > Code Snippet Manager and place them under the appropriate language.
Once imported (you may need to restart Visual Studio) you type the shortcut and hit tab... i.e. bigc then TAB.
File: bigc.snippet
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Crazy Big Comment</Title>
<Description>Inserts a crazy big comment block.</Description>
<Author>Steve Fenton</Author>
<Shortcut>bigc</Shortcut>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="CSharp" Kind="any">
<![CDATA[
// ************************************************************************
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
There are instructions on creating custom snippets on Codeproject - written for 2010, but applicable to 2012.

Although not the same exact thing as you're asking for, but I think supplies the same functionality and a little more.
There are Regions you can use in Visual Studio that would break your code into sections that are shrinkable and expandable for easy separation of code blocks.
For Example:
#Region "This is the code to be collapsed"
Private components As System.ComponentModel.Container
Dim WithEvents Form1 As System.Windows.Forms.Form
Private Sub InitializeComponent()
components = New System.ComponentModel.Container
Me.Text = "Form1"
End Sub
#End Region
Source:MSDN

If you're writing procedures large enough to warrant separating out sections into individual code blocks, I'd suggest that's a good point to start creating sub procedures. Visual studio provides support to make a sub procedure if you select the code and right click Refactor | Extract method.
Alternatively, have you looked at the regions keyword? This has intent similar to your requested functionality but has support from the Visual Studio IDE. http://msdn.microsoft.com/en-us/library/9a1ybwek(v=vs.110).aspx

Related

Xamarin NetStandard Android sfChart DateTimeStripLine not displayed?

This is fairly specific (as the title suggests).
I've recently ported my Xamarin Forms app to NETStandard, and now my sfChart DateTimeStripLine are not visible on Android.
Things show up more-or-less fine on UWP, so I don't think I've introduced regressions.
Anyone else having similar experiences? Has anyone successfully used ChartStripLine on NET Standard?
We have prepared a sample using DateTimeStripline in SfChart with .Net Standard 1.3 and it’s working fine in this sample. If still you face the problem, please provide Stripline related code snippet, it would be helpful to provide better solution.
So, finally figured out the issue:
The StripLines declared in XAML work fine, but binding to a StripLineCollection did not (android only). Unfortunately, declaring in XAML is not a particularly useful option.
To fix/workaround, declare StripLine in XAML like so:
<chart:DateTimeAxis x:Name="TheTimeAxis" ...>
<chart:DateTimeAxis.StripLines>
<!-- Empty def requires at least one item to be used
This creates container to fill in ViewModel.
Fixes dissappearing StripLines bug on android -->
<chart:DateTimeStripLine WidthType="Day" Width ="1"
Start="09/28/2017">
</chart:DateTimeStripLine >
</chart:DateTimeAxis.StripLines>
Then, in the code behind access the named axis, pull out the striplines and modify to your hearts content.
// Workaround Android: Our StripLines do not appear to be
// refreshing when bound from XAML. To fix we create in XAML,
// then retrieve the existing collection and pass that to the
// viewmodel for modification
DateTimeAxis sl = this.TheTimeAxis;
var slc = sl.StripLines;

Need to modify XLIFF XSD

I am converting DITA to XLIFF. In my technical solution I have to specialize (modify) xliff-core-1.2-strict.xsd to accommodate few DITA attributes. It means some attributes will go along with "g" tag. For Example:
<g id="00001" newAtt="this is new attribute" xid="009"/>
From the translation side I am not sure how it will work, so my questions:
Is it general practice that LSPs will get different flavor of XLIFF XSDs from different companies?
And is it possible for them to use it in their XLIFF editor by updating updated XLIFF XSD? I tried to explore “Transolution” but did not find any place where to place modified XSD.
Please let me know if you have any thought on this.
Thanks.
Here are my answers to your two questions:
I work for an LSP and I've seen all sorts and flavors of Xliff. Most of them try to stick to OASIS 1.2 transitional schema. Some of TMS/CAT producers added their own extensions. These producers normally provide an XSD so you can validate their Xliffs by adding that XSD to OASIS schema; e.g. SDL extensions to 1.2. When I'm customizing Xliff for a client, I normally do namespaces and provide a simple additional XSD; e.g.:
<trans-unit id="0" translate="yes" resname="msg_foo">
<superduper:uri>http://foo.bar/iJKLM9</superduper:uri>
<source>This is supposed to be a <superduper:g id="00001" newAtt="this is new attribute" xid="009"/> example.</source>
<target state="new"></target>
</trans-unit>
Most of the TMS/CAT tools are very basic (and closed) when it comes to their Xliff filters (or any of their filters for that matter) and I'm sorta kinda sure that they ignore your customized XSD.
Transolution is a very nice tool and my favorite Open Source translation tool. Unfortunately it's been long abandoned and has plenty of defects and shortcomings.
Anyway, if you provide a sample file, I can tell you what happens to non-conforming tags when it's imported into one of common, major CAT tools.
One final note; <g> seems to be retired in Xliff 2.0.
Forget about Transolution for one thing. I would try it with Trados, MemoQ or MemSource. Those are some of the big tools used in the translation business.
Personally I never got an XLIFF with a XSD, nor do I think Trados can handle it.
What do you need to change in the XLIFF?

How to keep the generated TLB file neat?

Hi I use interop to call C# code in Delphi.
C# code has a binary and in Delphi 5 Menu: Project-->Import Type Library
Click Add to add the tlb file: XXXX.tlb
Unit dir name: input the path where the delphi XXX_TLB.pas file is generated.
If the C# dll, tlb and delphi XXX_TLB.pas has already been there. Now I add one more function in C# code and hope Delphi can call this function as well. I need to recompile c# and regenerate delphi XXX_TLB.pas file. But by following the above steps, I see the newly generated XXX_TLB.pas includes my newly added function, but looks like the functions order in XXX_TLB.pas is totally different from before.
For example, in my C# binary I have function:
func1();
func2();
func3();
func4();//newly added
In the old XXX_TLB.pas, the function order is:
func1();
func2();
func3();
Now XXX_TLB.pas is like this:
func1();
func3();
func4();
func2();
The XXX_TLB.pas can still be used, looks like no functionality difference, but when I check in to tfs, I see it changes a lot from pervious version. Is there a way to keep this new XXX_TLB.pas the same order as before but add my function as well? How to do that? Thanks!
You cannot hope to keep the changes to a minimum unless you start writing the .pas file yourself. That sounds like a worse option.
Probably what is happening is that you have changed version of either one of your compilers since the last time you imported. Otherwise one would expect minimal differences.
Just check it in with a comment stating which versions of compiler and .ocx/.dll were used.
You can't, as far as I know.
I most cases, I'm able to consider them as a sort of "black box" anyway, and only occasionally have to peek in them to find a specific declaration.

How I can add some items to the code completion combobox of the Delphi IDE

I'm working in a Delphi IDE expert and I wonder if it's possible add new items to the code completion combobox displayed by the Delphi IDE when the user press CtrlSpace
UPDATE:
What I need is add items to the code completion list based in a specified type.
example suppose which I have a type called TMytype, what I want to do is add addional items to the code completion list when the user type a variable of the type TMytype
check this image
I found your question somewhat confusing but if you are in search of credible source on "Custom Live Templates" and the like on Delphi, head to the blog of Cary Jensen here.
Edit:
Looking forward to further improvement of the scope of the question, I suggest here another direction to explore:
Source code manipulation using IOTAEditor, IOTASourceEditor, IOTAEditReader and the like
Some Parsing for sanity check prior to apply any modification.
Adoption of Client DataSet as a format to store data (It's serializable) to simplify the coding of IDE editors.
Perhaps I haven't fully grasped the extent of what you are asking here, but you can add templates simply by going to 'View|Templates' from the Delphi IDE. This then opens a template viewer. Press the '+' icon. It opens a template1.xml document which you can then edit so create your new item.
If you wish to do this programatically, just add an xml file (of the same format) to the ..\RAD Studio\code_templates folder.

F# Fractal - a bug I can't figure out

I'm trying to make an example I've found on the net work. It's a 3D fractal in F#. Here it is: http://tomasp.net/blog/infinite-cheese.aspx. The source code is available for download at the end of the article. The article and the sample were written in 2007, so I think the code is just slightly obsolete. There is one block of code that causes error and the code won't compile:
// Returns a cube with filtered sides
let private get_cube(incl_sides) =
[ for (side,trigs) in cube
when Set.mem side incl_sides
->> trigs ]
The when keyword is underlined, and the error message goes as follows:
Unexpected keyword 'when' in expression. Expected '->' or other token.
I can't figure out what's wrong with this. In an attempt to understand the code better, I searched the langauge specs. As far as I know, there is nothing about the Set.mem function or the ->> operator. Do you have any idea what could be wrong?
Try
[for (side, trigs) in cube do
if Set.contains side incl_sides then
yield! trigs]
The language has undergone a lot of changes since that code was written. In particular, the ->> operator has been replaced by yield!, Set.mem has been renamed to the more descriptive Set.contains, and comprehensions now use if ... then instead of when.
Yes, the version of the source code that is linked from the blog post is a bit old. You can find the latest (updated) version in the F# samples project on CodePlex. I think there may be some other changes, so it is best to get the version from CodePlex. (It includes FractalSimple.fs which is simpler version and Fractal.fs which also removes cube sides that are not visible).
The project contains standard Visual Studio 2008/2010 .fsproj project. The original version on the blog was written using F# CTP (from VS 2005 times) which had a completely different Visual Studio integration and used an obsolete .fsharpp project format (before MSBUILD format existed).
The when and ->> constructs have been used as a lightweight syntax for writing queries, but are now deprecated, to keep the syntax inside comprehensions consistent with the rest of the language. As kvb points out, you can use ordinary if .. then and the only non-standard thing is yield!, which means return all elements of the given sequence.

Resources