VS13/VS15 - can't import SQL snippet - sql

I would like to create SQL snippet in VS2013 and VS2015. I don't know why, but I've got an error while importing (in both of VS):
"C:\sql.snippet: Missing or unspecified Language attribute"
My snippet:
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2008/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
My Snippet
</Title>
</Header>
<Snippet>
<Code Language="SQL">
<![CDATA[select * from MyTable]]>
</Code>
</Snippet>
</CodeSnippet>
What's wrong?
The language SQL should be OK https://msdn.microsoft.com/en-US/library/ms171418.aspx#code
I tried to add this snippet to language "Miscrosoft SQL Server Data Tools, T-SQl..."
If I've changed the language attribute to e.g. CSharp it works.

Instead of:
<Code Language="SQL">
Write:
<Code Language="SQL_SSDT">
Visual Studio supports only MSSQL Server Data Tools & T-SQL Language Scripts, not SQL like SSMS does.

Try this.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
My Snippet
</Title>
</Header>
<Snippet>
<Code Language="SQL">
<![CDATA[select * from MyTable]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
You could also check this out if it works but still gives a warning.
http://providersweb.blogspot.se/2016/01/visual-studio-snippets-missing-or.html
I have been getting a list of messages in the Snippets output window
when I load a project that a number of snippets had a 'missing or
unspecified language attribute' and could not figure out why these
messages appeared. I had checked the Language attribute on the
snippets and they were correct, but still got the message. I had set
up folders for each language type, but still got the messages. I
finally figured out that I had specified they all were VB snippets in
the Snippet manager and those that were not VB would cause the
messages in the output window, ie when loading a VB project, the
CSharp snippets would generate the error message. I fixed this by
going into the snippet manager and specifying the Language, VB or
CSharp, and adding the snippets to the correct language and removing
them from the invalid language. And now these messages of invalid
language attributes do not appear on my output screen.

The language attribute value you used, SQL, is correct. From the VS2015 Code Snippets Schema Reference:
Errors such as you're seeing can happen if you're editing a snippet file directly in one of the folders known by the Code Snippets Manager. Evidently Visual Studio holds its own metadata in addition to what's in the snippet XML itself. For this reason, it can be best to do the edits in a temporary folder and then use the Import button.
For example, I kept getting the error "Missing or unspecified Language attribute" when saving any edit to my new C# snippet in the My Code Snippets folder—or so I thought. Turned out I was in the Visual Basic\My Code Snippets folder, and there's also a Visual C#\My Code Snippets folder which is where I should have been. This was a silly mistake but it illustrates that the "Language" XML attribute isn't enough, as Visual Studio has its own internal conventions to do with different folders for different snippet types (and who knows what else) which all happens when the Import button is used.
I removed my snippet file to a temporary location, and then added it from there using the Import button. As soon as I did this, the problem went away and the snippet started working normally.

Related

Unable to embed a screenshot to the SpecFlow html Report

I am executing my automation scenarios using SpecFlow with Visual Studio.
I want to Embed a custom image to the HTML report which was generated by SpecFlow. That image is a screenshot i am taking whenever scenario is failed in Hooks.
Please help me out.
This is what i am seeing in the html report - enter image description here
Take a look at the SeleniumWebTest sample project here. This sample project shows how to include a screenshot in your report. While the example is Selenium-based, the same principles apply to other frameworks.
A more in-depth explanation of how this works can be found here under "Including Screenshots". Essentially, you need to abuse the console and use it to output your images' file paths.
Any data written to the console is available in your report (this is how the trace details are received by the report). You will need to parse the data written to the console and strip out the file path you want to embed. Make sure that you strip the image path completely so that you don't output the file path as part of the other trace information received from the console.
Edit: I've since discovered that there seems to be an issue with the template in the sample project. The following section in the template is bugged:
class="log">#Raw(FormatTechMessages(traceEvent.TechMessages.TrimEnd()).Replace("SCREENSHOT[ <a href="http://specflow.org/plus/documentation/,-/" data-page=",-"<img width='1000' src=").Replace("</a> ]SCREENSHOT", "</img>"))</pre>
This is because the console no longer seems to be formatting the file as a hyperlink, so the replacement string is never found. Updating this line in ReportTemplate.cshtml seems to have done the trick:
<pre class="log">#Raw(FormatTechMessages(traceEvent.TechMessages.TrimEnd()).Replace("SCREENSHOT[ ", "<img width='1000' src=\"").Replace(" ]SCREENSHOT", "\"</img>"))</pre>
As the console is no longer formatting the file as a hyperlink, you only need to replace the padding (in this case the "SCREENSHOT[]SCREENSHOT") from the string and instead enclose the path with the <IMG> tag. You also need to add the quotes around the file path.

Exporting code style settings from IntelliJ IDEA version 14.1.5

I'm using the updated version of the IntelliJ IDEA and am trying to export my code style settings so that they can be used by all developers working on a particular project. I read the tutorials at https://confluence.jetbrains.com/display/IntelliJIDEA/Code+Styles and http://forum.shakacode.com/t/sharing-your-intellij-rubymine-webstorm-codestyle-among-developers/240, which seems fairly simple.
Unfortunately that is not how my 'export settings' pane looks like, and I don't have a line that says 'code styles'. Mine looks like
The closest I can find is the line I highlighted which has CodeStyleSettingsManager in it along with a whole bunch of other stuff. However I tried using that and extracted the .jar file only to find that there was nothing much inside at all.
Does anyone know a way of exporting code styles that works with the latest version of IntelliJ?
Edit: My codeStyleSettings.xml file only contains the following:
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value/>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true"/>
</component>
</project>
I don't understand, why you don't see Code Style in your list (it appears in my IDEA 14.1.5), but...
(...) export my code style settings so that they can be used by all developers working on a particular project
A better way to share the project code style across all developers is to include it in your VCS repository. Pulling such a commit will apply those code styles automatically. This is the file: project/.idea/codeStyleSettings.xml. If your VCS is set to ignore .idea/, add an exception for this file.
If you don't see this file at all, you're probably using a local formatter and your Project scheme is unchanged. In this case, go to Settings > Editor > Code Style > Scheme: Manage, select your formatter and click Copy to Project.
Update
Code style files only state the difference to the IDEA Default Code style (which is always the same). You can try this yourself: create a new project, go the the Code Style settings, select Project and change only one option. The codeStyleSettings.xml file will be created, and it will contain only this one option. If you could export your code style settings, the output would be exactly the same.

SharePoint 2010 to 2013 SharePoint Migration issues

I recently migrated custom WebPart template solution (wsp), which has custom list definition, from SP2010 to SP2013 using Visual Studio 2013. Set the Assembly Version to 15 and compiled over .Net Framework 4.5. The deploymnet was successful. But there are 2 problems:
1. When I created site using the custom template that was just deployed, the page displays cluttered icons, attached screen shots. Also when trying to add permission to the site, a whole bunch of colorful cluttered icons appear on the site's Permissions page.
2. The other issue is, some of the CSS, specifically the ms-WPxxxxxxxx (like WPTitle, WPHeader etc) are being inherited, probably from corev4.css. That’s what View Source shows. The custom CSS is defined in the main page (CustomDefault.aspx) with “!important” tag, but that didn’t seem to be of any use.
The same solution was working perfect on SP2010.
Suspect mostly (1) is related to (2), I may be wrong.
To resolve (1), as advised by SP folks from MSDN Community forum, I changed the default master page to Oslo.master ==> that cleared the cluttering icons, but CSS and Javascripts werent working. So I had to revert.
I also tried changing the "../_layouts/.." to "../_layouts/15/..", that didnt make any difference.
MSDN Community Thread:
https://social.msdn.microsoft.com/Forums/office/en-US/f9199e0c-972b-45b9-b8fb-772028bc22d9/cluttered-icons-in-sharepoint-2013-post-migration-from-sp2010?forum=sharepointdevelopmentprevious#74fb3648-9776-4f68-82ba-b212102a1492
Any help will be appreciated.
enter image description here
After a long battle, I finally fixed this problem. Found that the 'onet.xml' in the SiteDefinition module was referring to SharePoint 2010 master page, v4.master. Since this was another project, I did not have a clue that this file will have references to SP2010 resources. Many blogs suggested only to change the resources path like '/_layouts/' to '/_layouts/15/' and the '/ControlTemplate/' to '/ControlTemplate/15/' but not seen anyone mentioning about master page change. Probably may not be the case for a completely out-of-box solution. So search for 'v4.master' (SP2010), in the project solution, if found, change it to your custom master page, if you have one, or to the default master page. But if you have used any other master page or a custom master page that was exclusively meant for SP2010 or an older version of SharePoint, you would have to choose an equivalent one or customize it to make it compatible with SP2013.
So here's the code snippet that was changed and that got rid of the cluttering icons, hope it helps someone out there.
<!-- <Configuration ID="-1" Name="NewWeb" MasterUrl="_catalogs/masterpage/**v4.master**" />
<Configuration ID="0" Name="Default" MasterUrl="_catalogs/masterpage/**v4.master**">
<Configuration ID="1" Name="Blank" MasterUrl="_catalogs/masterpage/**v4.master**">
<Configuration ID="2" Name="DWS" MasterUrl="_catalogs/masterpage/**v4.master**"> -->
<Configuration ID="1" Name="NewWeb" MasterUrl="~masterurl/**default.master**" />
<Configuration ID="0" Name="Default" MasterUrl="~masterurl/*default.master*">
<Configuration ID="1" Name="Blank" MasterUrl="~masterurl/**default.master**">
<Configuration ID="2" Name="DWS" MasterUrl="~masterurl/**default.master**">

SDL Trados Studio XLIFF global attribute has been already declared

Not sure if this is the right place to ask the question, but...
I've got the following xliff file:
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file1.txt" datatype="plaintext" source-language="de-de" target-language="en-us">
<body>
<trans-unit id="unit_5">
<source xml:lang="de">unit_5</source>
</trans-unit>
</body>
</file>
</xliff>
I try to open the document as "translate single document" and get the following error from the image below. What might it be?.
I just opened your xliff file in Trados Studio 2014 (SP1) without any error messages coming up. I am afraid I do not really understand what Studio was complaining about for you: the file looks fine to me.
Did you try to disable schema validation in the file type settings for XLIFF, just as a workaround?
Best,
Jenszcz
Generally, file[source-language] and trans-unit[xml:lang] should have the same value. I'm not sure if it's allowed to use different notations (de, de-de).
Also, I've found Trados to be a bit strict and sometimes you'll see that even if the specs allow for some elements to be missing, in some cases Trados still expects them to be present. I'd try putting the target node inside trans-unit and see if it works.
From the XLIFF 1.2 spec:
The optional xml:lang attribute is used to specify the content language of the <source> this should always match source-language as a child of trans-unit but can vary as a child of alt-trans.
So I think it's probably the mismatch between de and de-de that is causing the complaint. You could align these values, or just remove xml:space from the <source> element entirely, as it is optional in this context.

Multiple CodeSnippet in an XML .snippet file

I'm attempting to supplement the help features for my code by providing other developers with code snippets. These produce skeletons of code which demonstrate how to use/call my classes or methods.
I've created a .snippet file and have placed it in the "%Visual Studio Folder%\Code Snippets\Visual Basic\My Snippets" folder. I've used the Code Snippets Manager and ensured that it included this folder so that I can access the snippets.
Everything works well when I have 1 CodeSnippet tag within the root CodeSnippets tag....
When I add more than one CodeSnippet tag to the file (each with their own title, and their own code example) I'm experiencing something strange.
The first CodeSnippet I've added contains code for adding something to my system, the second contains code for editing something in my system, and the third deleting something from the system.
When I use the code snippet by right clicking and selecting "Insert Code Snippet", only the first code snippet in the file shows up as an option. When I select it, the code in the first CodeSnippet is inserted....but so is the code within the other CodeSnippet tags.
Do you have to have a separate XML .snippet file for each code snippet you want to make available?
After reading through MSDN about creating Code Snippets I was under the impression that this could all be done within one file.
It seems that I'm not understanding something very basic here and would love to find the answer but apparently Code Snippets are under used so finding the answer has proven to be a little trickier than I first thought it would be.
Thanks,
-Frinny
Do you have to have a separate XML .snippet file for each code snippet
you want to make available? After
reading through MSDN about creating
Code Snippets I was under the
impression that this could all be done
within one file.
I create and use snippets all the time. I wanted to do exactly what you intend. But, I have never gotten multiple snippets in one file to work. I also was under the impression you could do this. I even found an article, based on the beta version of Visual Studio, that demonstrated how to do this, but it didn't work. Moreover, the documentation states:
CodeSnippet Optional element. -
Parent element for all code snippet
data. There may be zero or more
CodeSnippet elements in a CodeSnippets
element.
I eventually gave up and created separate files. I have not tried multiple snippets in one file with VS2k8 yet.
Update
I cannot get VB to support multiple snippets in one file using VS2k8. I used the following snippet as a test case. Snippet taken from http://msdn.microsoft.com/en-us/library/ms165394.aspx. Only the first CodeSnippet is read/loaded/used. I also counted all CodeSnippet elements in all snippet files (1143) and no file has more than one. Moreover, this snippet duplicates the behavior you noted in your question. Using the snippet inserts both message box statements.
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2008/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>
SECOND Snippet
</Title>
</Header>
<Snippet>
<Code Language="VB">
<![CDATA[MsgBox("SECOND SNIPPET")]]>
</Code>
</Snippet>
</CodeSnippet>
<CodeSnippet Format="1.0.0">
<Header>
<Title>
FIRST Snippet
</Title>
</Header>
<Snippet>
<Code Language="VB">
<![CDATA[MsgBox("FIRST SNIPPET")]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
More Info
I got to thinking that this has to be a bug that slipped through because Microsoft never put multiple snippets in the provided snippet files that come with Visual Studio, or VB.NET doesn't support multiple snippets due to difficulties integrating with the enhanced statement completion capabilities of the editor.