I'm building several ruleset files with all the same rule IDs but ascending levels of included MS rulesets and increasing severity of the Action for some of the rules. The problem I'm having is that VS2010 is telling me there's an error loading my FXCop_VS2010_HIGLevel2.ruleset file while the FXCop_VS2010_HIGLevel1.ruleset loads fine. They essentially look the same:
FXCop_VS2010_HIGLevel1.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="HIG VS2010 Code Analysis Rules Level 1" Description="These rules expand on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code." ToolsVersion="10.0">
<Include Path="BasicCorrectnessRules.ruleset" Action="Default" />
<Include Path="SecurityRules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1000" Action="None" />
<Rule Id="CA1001" Action="None" />
...
<Rule Id="CA2239" Action="Warning" />
<Rule Id="CA2240" Action="None" />
<Rule Id="CA2242" Action="None" />
<Rule Id="CA2243" Action="None" />
</Rules>
</RuleSet>
FXCop_VS2010_HIGLevel2.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="HIG VS2010 Code Analysis Rules Level 2" Description="These rules expand on the basic design guideline rules to maximize the usability and maintainability issues that are reported. Extra emphasis is placed on naming guidelines. Consider including this rule set if your project includes library code or if you want to enforce the highest standards for writing maintainable code." ToolsVersion="10.0">
<Include Path="BasicCorrectnessRules.ruleset" Action="Default" />
<Include Path="BasicDesignGuidelineRules.ruleset" Action="Default" />
<Include Path="SecurityRules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1000" Action="Warning" />
<Rule Id="CA1001" Action="None" />
...
<Rule Id="CA2239" Action="Warning" />
<Rule Id="CA2240" Action="None" />
<Rule Id="CA2242" Action="None" />
<Rule Id="CA2243" Action="None" />
</Rules>
</RuleSet>
You can see that they're essentially the same. Level 2 adds the BasicDesignGuidelineRules.ruleset and changes the actions on some rules (i.e. CA1000 goes from "None" at Level 1 to "Warning" at Level 2).
This is the error I get from VS2010 when I put the Level 2 ruleset file into the Static Analysis Tools\Rule Sets folder:
Any ideas why this is happening? I went through the Level 2 XML line by line and I ran a file compare to the Level 1. The only differences are what I expected. I used Notepad++ to display non-printing characters and nothing other than CRLF in the appropriate places. I'm stumped.
As you privided in your comment, you said the problem got resolved after changing the Actions from CriticalWarning to Warning, and CriticalError to Error.
This behaviour is explained here: http://msdn.microsoft.com/en-us/library/dd380626.aspx
You must have mistaken the action for the MessageLevel property in custom rules XML-files. In this property you can set the following values:
Critical Error – Issues reported with this level have high visibility and the identified code does not operate correctly in
most common scenarios. These issues should be resolved first. You
should not exclude issues with this level.
Error – Issues at this level have less visibility and impact. But it still identifies issues in your code you need to resolve. Also
these issues should not be excluded without careful consideration.
Critical Warning – This level is mostly used for maintainability issues of your code. The code is working correctly but
less-than-optimal. Exclude such messages only after careful
consideration.
Warning – Messages with this level are identifying issues in your code around maintainability, extensibility and stability.
Informational – Informational messages about the code.
Related
I'm trying to merge .edmx file using TortoseGIT, but I am getting to conflicts where I do not know what the codes mean with connectorPoint differences?
See screenshot here:
Has anyone delt with this?
<ConnectorPoint PointX="5.5" PointY="65.78099659375" />
<ConnectorPoint PointX="7.7760391666666671" PointY="65.78099659375" />
<ConnectorPoint PointX="8.1614608333333329" PointY="65.78099659375" />
<ConnectorPoint PointX="10.40625" PointY="65.78099659375" />
<ConnectorPoint PointX="10.40625" PointY="64.74949218750001" />
It looks as though connectorpoints were added to both branches. Since there was an addition, git doesn't know which to take (yours or theirs), which is why there is a merge conflict.
You probably want to take both additions, so all the connector points exist, but this may be a trial and error type of problem. After merging, you can always undo your merge and try again.
From my VS2010 deployment project I would like to apply two different transformations to two different attributes of one element in my web.config. Consider the following web.config snippet:
<exampleElement attr1="false" attr2="false" attr3="true" attr4="~/" attr5="false">
<supportedLanguages>
<!-- Some more elements here -->
</supportedLanguages>
</exampleElement>
Now how can I change attribute 'attr1' and remove attribute 'attr5' in the transformed web.config? I know how to perform the individual transformations:
<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
and:
<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
But I don't know how to combine these transforms. Anybody?
EDIT:
Can't answer my own question yet, but the solution seems to be:
It seems that it is possible to repeat the same element with different transformations, like so:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
</configuration>
As said, this seems to work, but I'm not sure whether this is the intended use of the web.config transformation syntax.
As Nick Nieslanik confirmed this is done by repeating the same element with different transformations, like so:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
</configuration>
I'm using XmlPreprocess tool for config files transformations & manipulation. It is using one mapping file for multiple environments. You can edit mapping file by Excel. It is very easy to use.
You can update your config files with xmlpreprocess and use configuration (debug, dev, prod,...) as a parameter for the different setup...
It has come to my attention that http://www.example.com/Home/About is considered completely different from http://www.example.com/homE/abouT, yet they are the same page and both have header response of 200.
These URL's should either be all lower or upper case and any variation should return a 301 and redirect to the all lower or upper case URL.
This may be ok with an “AboutUs” page but if you are per say a large store front with a large number of products this could kill any ranking you have or may attain in the future.
Wish MVC/ASP.NET can some kind of option to set strict URL’s in the routing engine.
Just use a canonical url with consistent capitalization and you shouldn't have any SEO issues even if people link to a differently cased version of your url.
that's what the canonical link is for.
and just because you can hard-type these urls into the search bar, it doesn't mean that search engines will index them like that. As long as you refer to your URLs in the same way, it won't be a problem.
So rewrite your URLs to be all lower case.
http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/
<rule name="Convert to lower case" stopProcessing="true">
<match url=".*[A-Z].*" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
</rule>
Problem solved!
Incidentally, even if you don't specify a canonical URL, Google is generally smart enough to figure out what's malicious vs. unintentional duplicate content. I'd imagine their algorithm is smart enough to know that two pages with the same content and only capitalisation changes in the URL aren't some attempt at gaming their crawler.
Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.
This is a free plug-in that does what you are asking: http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=800978aa-2aac-4440-8bdf-6d1a76a5c23c
Update
Unfortunately the link is outdated. You can download Regionerate at http://www.rauchy.net/regionerate/docs/2007/05/download.html
If you are using Resharper, you can change the Type Members Layout template so that it orders your code however you like. See under Resharper>Options>Languages>C#>Type Members Layout.
alt text http://www.jetbrains.com/resharper/features/screenshots/40/automatic_member_layout_full.png
You can, for example, put methods with particular attributes first in your file... e.g. methods marked with NUnit's [Setup] and [TearDown] could come before methods marked with [Test] by placing a block like:
<!--Fixture Setup/Teardown-->
<Entry>
<Match>
<And>
<Kind Is="method"/>
<Or>
<HasAttribute CLRName="NUnit.Framework.TestFixtureSetUpAttribute" Inherit="true"/>
<HasAttribute CLRName="NUnit.Framework.TestFixtureTearDownAttribute" Inherit="true"/>
</Or>
</And>
</Match>
</Entry>
before:
<!--Test methods-->
<Entry>
<Match>
<And Weight="100">
<Kind Is="method"/>
<HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/>
</And>
</Match>
<Sort>
<Name/>
</Sort>
</Entry>
and then have a catch-all for everything else:
<!--All other members-->
<Entry>
<Sort>
<Name/>
</Sort>
</Entry>
The template system is very powerful and should meet your needs.
You may find or be able to make a macro to do this, but there is no built in functionality of VS to sort your methods. Some third party productivity tools like Resharper and CodeRush provide some functionality to reorder your code.
ReSharper has Code Reordering functionality and a File Structure view that lets you do drag and drop reordering.
Resharper will do a good job in a limited way. It depends on how much you want. For example, it wont go and reorder your overrides in an asp.net page based on lifecycle, or anything like that, but it will keep properties, fields, methods and what not clearly grouped
EDIT: By the eway i was refering to auto reordering aka reformatting.
I have a number of solutions with a large number of projects in them. I would like to be able to define global settings for the solution that are used by all projects. For example an include directory. I want to be able to change the include directory in one place for all projects in the solutions.
When I searched for a solution I found a good description of the problem that matches mine exactly but the solution suggested there, project property sheets, are defined per project and not per solutions.
I could use environment variables or Visual studio settings, but then everyone that needs to compile the code has to define the exact same settings.
Can anyone suggest a way to do this? Thanks.
We use property sheets to accomplish this. A single property sheet can be assigned to all the projects in the solution. From then on you can change a setting in that one property sheet and it will affect all the projects.
Advanced tip: We actually use multiple property sheets, (e.g. one for release target types, one for debug target types). The tip is that the order is very important. If you're editing the project files by hand then the last property sheet will override settings in the previous property sheets in the list. If you're editing in the GUI, then the TOP one overrides the ones below it.
As others have suggested, property sheets can do what you want. The trick is to use InheritedPropertySheets as you would use #include in C++. NOTE: the XML is slightly different for project files and property sheet files. Here's a contrived and simplified example of two projects (prjA.vcproj and prjB.vcproj) including the same property sheet (sln.vsprops) which itself includes another (strict.vsprops):
strict.vsprops
<VisualStudioPropertySheet ...>
<Tool Name="VCCLCompilerTool" WarningLevel="3" WarnAsError="true"/>
</VisualStudioPropertySheet>
sln.vsprops
<VisualStudioPropertySheet ... InheritedPropertySheets=".\strict.vsprops">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="NOMINMAX=1"
RuntimeTypeInfo="true"
/>
</VisualStudioPropertySheet>
prjA.vcproj
<VisualStudioProject ...>
<Configurations>
<Configuration ... InheritedPropertySheets=".\sln.vsprops">
</Configuration>
</Configurations>
...
</VisualStudioProject>
prjB.vcproj
<VisualStudioProject ...>
<Configurations>
<Configuration ... InheritedPropertySheets=".\sln.vsprops">
</Configuration>
</Configurations>
...
</VisualStudioProject>
You may also find this question and its answers useful.
Maybe you could add an MSBuild file to your solution in which you define a number of shared properties, and then <Import> that file into all your real projects?
That is, in your "settings" MSBuild file you define a number of properties:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WinUnitIncludeDir>C:\Includes\WinUnit</WinUnitIncludeDir>
<!-- Other shared properties go here -->
</PropertyGroup>
</Project>
From your real projects, you can then refer to this:
<Project ...>
...
<Import Project="path/to/settings.msbuild" />
...
<Configurations>
<Configuration ...>
<Tool Name="VCCLCompilerTool"
...
AdditionalIncludeDirectories="$(WinUnitIncludeDir)"
... />
...
...
...
</Project>
As suggested, you should look at Property Sheets (aka .vsprops files).
I wrote a very short introduction to this feature here.
I searched exactly the same thing some time ago but didn't find exactly what i wanted.
The only thing that might be close to this feature are Property Sheets. That's not exactly global as it's owned by a project and used by others.