Spell checking of the comments was added to the recent versions of StyleCop. It seems I can reuse my existing CustomDictionary file (that I created for FxCop) with StyleCop. SA1650 rule documentation does not say that it is possible. But in release notes for version 4.7.39 I see
Add support for specifying dictionary folders in the settings.StyleCop
file.
How do I configure StyleCop to search for this file in the root folder of my solution?
In my case it worked when I specified the custom dictionary entries in the Settings.StyleCop file located next to the .csproj file.
<GlobalSettings>
<StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
<CollectionProperty Name="RecognizedWords">
<Value>word1</Value>
<Value>word2</Value>
...
</CollectionProperty>
</GlobalSettings>
Actually, the StyleCopSettingsEditor.exe utility created these settings for me. I opened it using the project's context menu in Visual Studio, using the "StyleCop Settings" menu item.
Add a file named Settings.StyleCop in your solution root directory with the following content:
<StyleCopSettings Version="105">
<GlobalSettings>
<CollectionProperty Name="DictionaryFolders">
<Value>**my-dictionary-folder**</Value>
</CollectionProperty>
</GlobalSettings>
</StyleCopSettings>
Where you replace my-dictionary-folder with the relative path to the folder containing your CustomDictionary.xml file.
According to the StyleCop documentation for rule SA1650
The CustomDictionary.xml file should be placed in the same folder as the StyleCop.dll and the Rules. That folder (and all subfolders) are checked for the dictionary files.
StyleCop loads CustomDictionary.xml, CustomDictionary.en-GB.xml and then CustomDictionary.en.xml (where en-GB is the culture specified in the Settings.StyleCop file).
StyleCop also loads custom.dic, custom.en-GB.dic and then custom.en.dic (where en-GB is the culture specified in the Settings.StyleCop file).
Recognized words can also be added to the Settings.StyleCop file using the Settings Editor on the spelling tab.
So it appears that you would have to put a copy of CustomDictionary.xml in that specific location rather than in the root of the solution folder.
A similar question has been asked here http://stylecop.codeplex.com/workitem/7422 and there is an open ticket here http://stylecop.codeplex.com/workitem/7435 which I believe will provide what you're looking for if it gets done.
Related
Enable the XML documentation file from the C# Project Properties > Build tab.
Build the project
By default, git will suggest adding this to the repo.
Since it's a build artifact, this is not desired.
However, it needs to be manually excluded for each instance in e.g. gitignore files.
Are you really using these XML Document files? We weren't using them, so our solution was just to disable generation of these files in each project (don't forget to update all configurations).
If you are using XML Documentation files, you can put them in your output path and exclude the path. It appears this is the default to go to $(OutDir) or bin\Debug for example. They should be excluded by these rules:
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
If you put the XML files into your project directory for some reason, you could change the filename to add a pattern like $(Project)_XMLDoc.xml and then you could use the pattern:
*_XMLDoc.xml
I have created a C# project. I have created a Bitbucket account and want to put my project there.
What all should I put in the repository and what not to.
I am guess Debug and Release folders should not be uploaded. What about..
- Name/bin/Debug
- Name/obj/Debug
Thanks
It's a good idea to start with an established .gitignore file. GitHub has a project that maintains .gitignore files for various environments, including Visual Studio.
https://github.com/github/gitignore
Scroll down and grab VisualStudio.gitignore. Or you can download the file with this PowerShell command (set the current directory to the root of the repo, first):
(Invoke-WebRequest 'https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore').Content > .gitignore
This should give you an idea of what the general consensus is on what belongs in source control and what doesn't in a Visual Studio solution. In particular, this will exclude the bin and obj folders so you don't commit outputs to the repository, as well as the .vs folder and *.user files, which are user-specific data. It also excludes files and folders used by popular third-party extensions that maintain their own user-specific data.
Once you have a good .gitignore file, you can use git add --all and it will add everything that's not ignored to the index.
Nothing in bin or obj should need to be committed. You'll also need csproj files and nuget package config files (be they xml or json). Things like appconfig files, and .vscode are up to you whether you want to have them in source control.
i am using visualstudio.com as TFS online and have created my code repo there.
In my project there is folder that comprises several subfolders and eachsub folder has several images (the total of all images is like 6000).
When i check-in my code I do not want the root folder (i.e. the parent folder of image subfolders) and its content to be checkedin?
I tried online for some answers but cannot find anything accurate.
Thanks in advance for your help.
You can configure which kinds of files are ignored by placing text file called .tfignore in the folder where you want rules to apply. The effects of the .tfignore file are recursive. However, you can create .tfignore files in sub-folders to override the effects of a .tfignore file in a parent folder.
To create the file, the easiest way is using the auto automatically generated .tfignore file, follow below steps:
In the Pending Changes page, in the Excluded Changes section, choose
the Detected changes link.
The Promote Candidate Changes dialog box appears.
Select a file, open its context menu, and choose Ignore this local
item, Ignore by extension, Ignore by file name, or Ignore by folder.
Choose OK or Cancel to close the Promote Candidate Changes dialog
box.
A .tfignore file appears in the Included Changes section of the
Pending Changes page. You can open this file and modify it to meet
your needs.
More info please check the Customize which files are ignored by version control from MSDN Link:Add files to the server
Method 1:
There's an easy way to do it, i.e. via the .tfignore file. Go to the root folder of your and tfs checkin and put following content in the .tfignore file. If the file is not there create it.
.tfignore
<rootfoldername>
Method 2:
To exclude a file from source control
In Visual Studio, open Solution Explorer and select the file to
exclude.
On the File menu, click Source Control, then click Exclude
from Source Control.
When you are ready to place the file under
source control, you can access the File menu and click Source
Control, then uncheck Exclude from Source Control.
Edit:
This question is a possible duplicate of
How to ignore files/directories in TFS for avoiding them to go to central source repository?
Edit:
Changed the file name to .tfignore
I would like to have StyleCop rules apply on a specific namespace (all classes from this namespace are in the same folder).
My project structure looks like this:
Folder1
Class1.cs
Class2.cs
Settings.StyleCop (namespace settings)
Class3.cs
Class4.cs
Settings.StyleCop (general settings)
The general settings are correctly applied to all files (including the ones in the subfolder), but the namespace settings are completely ignored.
I haven't used StyleCop in a while, but I thought this was possible. Am I doing something wrong?
How can I make this work?
I don't think it's possible with Stylecop. I made some experiments and the rule file in the subfolder was always ignored.
I think it only works on a project level. I didn't go through the source code but placed a new C# file under the project without adding it to the project and it didn't analyze it which suggests it finds the code files by looking at the project file and ignoring any files just lying in that folder.
Also if you delete the Settings.Stylecop file under the project folder and select Stylecop Settings in Visual Studio it automatically creates a new Settings.Stylecop file even if you don't save the settings which also made me think it's highly coupled to the project file.
I'd suggest to move the contents of the Folder1 to a different class library and apply a different settings file to that project. You can merge settings with the other project and decide which rules apply to which project.
I have a main project directory with the following contents:
SubDirectory (Directory)
Project.sln (Solution File)
When I try manually changing SubDirectory's name in my Windows explorer, I get errors when I open the solution file. How can I rename this directory without affecting my solution?
Thanks!
Rename it in Visual studio, or edit the .csproj/.sln file with a text editor and fix the refrences.
Open the solution file in a text editor and rename all references to the old folder.
Open up the .sln file in notepad. You'll see a line like this:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "myproject", "myproject\myproject.csproj", "{DF81752F-37EE-4F4E-BC22-B09C8D05ED78}"
EndProject
If you want to rename the folder from myproject to newproject, you can change myproject\myproject.csproj to newproject\myproject.csproj (or whatever).
Change the name in SolutionExplorer.. it will work fine..
However it doesn't gurantee problem with Source Control or TFS you will need to resolve them manually
Your solution has the paths to your project files embedded in it, which includes the folder name. If you want to rename the folder, you have three options:
Close the solution. Rename the folder, then reopen the solution. The projects will show up as gray, and you'll need to click each one and locate the project file in the Properties window. Note that this may remove project references, but it may not. This is what I would suggest.
Open the solution and remove the project(s) within that directory. Note that this will remove any project references from any other projects that reference the project(s) that you're removing. Rename the folder, then add the project (and any project references) back.
Close the solution. Rename the folder, then open the .sln file in Notepad (or some other text editor) and fix the paths manually. This will preserve any project references.
When I have done it, I manually change it, then open the solution. You will get an error about not being able to find the project file, just choose to locate it, and it will re-map it. If you are using VSS, make sure everything is checked in first.
There are probably paths in project/solution related files that contain the old directory name. You'll either have to update those manually or find a way to rename the project from within Visual Studio.
This might help you rename the project:
http://msdn.microsoft.com/en-us/library/3e92t91t%28v=VS.90%29.aspx
In Visual Studio solution explorer,
edit the project properties to change
the assembly name, namespaces etc.
etc. to what you want.
Rename the top
Project nodes in VS solution explorer.
Shut Visual Studio down.
Open Windows explorer and rename your
folders and .csproj files to what you
want.
With a text editor and NOT Visual
Studio, open up the
sln file,
the .csproj files and
anything else you've renamed.
do a
Find & Replace looking for the old project strings, filenames,
namespaces (if required - I suggest
you leave that bit for when all has
been transitioned) and replacing them
as required.
I'm suggesting you'll
need to be selective because I don't
know how you've named your projects
and .csproj files ;-)
Once you've done all that, quit your
text editor and try opening up your
.sln file again.
Do a Rebuild the first time to remove any artifacts from the old configuration/naming.
HTH