Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude files from the JetBrains ReSharper commandLine tool InspectCode.exe

I'm hoping to demonstrate the value of ReSharper to my team. I want to try the commandline tool InspectCode JetBrains has released.

It runs fine when I point it at my solution, but analyses all the test projects, and some generated files. I want to exclude them from inspection. The documentation says

If you want to configure InspectCode on a CI server, you can make all configurations locally with ReSharper.

For various reasons I can't install even the demo version of ReSharper at the moment to do this. The InspectCode.exe tool can generate a configuration file, but it is not clear how I can manually edit this to exclude certain files or projects from analysis. Here is the auto generated XML file:

<?xml version="1.0" encoding="utf-8"?>
<InspectCodeOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NoSolutionWideAnalysis>false</NoSolutionWideAnalysis>
  <IncludedProjects />
  <SuppressBuildInSettings>false</SuppressBuildInSettings>
  <Debug>false</Debug>
  <Extensions />
  <Properties />
  <DumpIssuesTypes>false</DumpIssuesTypes>
</InspectCodeOptions>

How can I modify this XML file to exclude files ending in "generated.cs", or any file or project with "test" in the name?

UPDATE

derigel: I see what I did wrong. I have reset my ReSharper configuration and started again. Now all I changed in the settings was to go to ReSharper → Options → Code Inspection → Settings → Edit Items to Skip.

I added a file mask, "test".

Clicking save-to -> [SOLUTIONNAME] team shared saved it to the file as I expected. However the configuration file now looks like this:

<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002Atest_002A/@EntryIndexedValue">True</s:Boolean>

Which InspectCode.exe does not like. It gives me this error if I use /config=FILENAME.DotSettings:

Failed to load options from file
D:\SVN\Development\branches\OpenSolutionClinicalID_v1.0_Development\src\OpenSolutionConnect.sln.DotSettings.
Caused b y: System.InvalidOperationException: There is an error in XML document (1, 2). ---> System.InvalidOperationException:
http://schemas.microsoft.com/winfx/2006/xaml/presentation'> was not expected.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInspectCodeSettingsData.Read3_InspectCodeOptions()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at JetBrains.CommandLine.Common.Options.OptionsUtils.DeserializeFromFile[T](FileSystemPath pathToConfig)

like image 805
Pete Whitehead Avatar asked Feb 03 '14 08:02

Pete Whitehead


People also ask

What is the use of ReSharper tool?

ReSharper helps instantly get to any code in a solution, no matter how large the solution is. It can also navigate you from any symbol to its related code such as implementations of a given interface, extension methods of a class, or usages of a field.

How use ReSharper code review?

ReSharper helps you resolve most of the discovered code issues automatically. All you need is to press Alt+Enter when the caret is on a code issue highlighted in the editor and check the suggested quick-fixes.

How do I generate a ReSharper report?

In the main menu, choose ReSharper | Inspect | Load Saved Issues Report. Select an XML report file and click Open. The report is opened in a new tab of the Inspection Results window.


1 Answers

The documentation describe the settings for your solution, not the tool itself.

For example, here are settings for generated files: Configuring Code Inspection Settings and here about excluding files: http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Configuring_Warnings.html#d2375e201

After you change them and save to the solution-shared level, there will be file <solutionname>.sln.dotsettings which will be taken into account by command line tools.

Although this is an XML file, it's not very editable by hands. Why can't you install trial instance of ReSharper and configure all you need?

like image 93
derigel Avatar answered Sep 28 '22 03:09

derigel