The Lint tool for F# interprets comments and white space as lines of code. Thus, a warning is generated.
I think this is a bug.
Is there a way for me to disable the analyzer for counting lines on the Lint tool?
There are configuration options for Lint.
Visual Studio must be exited and restarted for the change to take effect.
Details for manually changing configuration
F# Lint uses an XML for configuration
which for my system is located in the src\FSharpLint.Framework directory.
For Lambda Functions maximum lines there is:
<MaxLinesInLambdaFunction>
<Enabled>true</Enabled>
<Lines>7</Lines>
</MaxLinesInLambdaFunction>
which also allows for the changing of the number of lines.
Details for Visual Studio
For Visual Studio from the menu
Tools -> Option
In the left panel select: F# Power Tools
Click on: Lint
In right panel
Select tab: Rules
Click Source Length
The message about lines in a lambda function is controlled by the option:
MaxLinesInLambdaFunction
If enabled the warning message is displayed.
If disabled the warning message is NOT displayed.
Related
I have written a code analyzer as part of my Visual Studio Package.
This corresponds to the instructions on this page except that it is part of my existing Package and not a stand-alone analyzer.
The analyzer registers itself to analyze the the SyntaxNode types StringLiteralExpression and InterpolatedStringExpression.
public override void Initialize ( AnalysisContext context )
{
context.RegisterSyntaxNodeAction ( AnalyzeString, SyntaxKind.StringLiteralExpression, SyntaxKind.InterpolatedStringExpression ) ;
}
As described here
By default, live code analysis executes analyzers only for open files in Visual Studio.
This is correct. My analyzer runs on open files.
The same page continues:
Run code analysis manually
In Solution Explorer, click the project.
On the Analyze menu, click Run Code Analysis on Project Name.
Code analysis will start executing in the background. You should see the message
Running code analysis for ... in the Visual Studio status bar towards
the bottom-left corner. Once code analysis completes, the status message will
change to Code analysis completed for . Error list will soon refresh
with all code analysis diagnostic
In this case, my analysis does not run.
I have placed breakpoints in the constructor, the SupportedDiagnostics property get, the Initialize function and the analyze function itself. None of them are entered if I start the code analysis manually via the Analysis menu (or via the context menu in the solution explorer).
Is there some additional condition required to activate a code analyzer for the manual code analysis?
I also encountered this weird issue.
In my case, I used the "wrong" Developer Command Prompt.
I installed VS Build tools after installing VS2017, which also installed the 2nd Developer Command Prompt.
The Start Menu shortcuts of the 2 Developer Command Prompt are as follows:
A: BuildTools (does not work!)
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"
B. VS Professional (works!)
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
I spent all afternoon trying to figure this out! :-(
I followed the getting started instructions and the "generate step definitions" is missing from context menu.
I tried adding the additional specflow packages from nuget for mstest and still nothing.
I had the same problem. I was looking for this option in contextual menu of the feature file, but this option exists in the contextual menu of the content of the feature file. So, try open the feature file (*.feature) in the Visual Studio text editor and click right button of the mouse inside text editor. Example of the file:
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
Assuming you are bringing up the correct context menu by right clicking in the .feature file as opposed to anywhere else then you may find that the issue is actually caused by the TechTalk.SpecFlow.dll not being referenced in your project.
To add the reference manually (NuGet didn't do it for me) right-click on the References folder of your project and find the TechTalk.SpecFlow.dll which will likely be in '[project]/packages/SpecFlow.X.X.X/lib/netXX/' (X's are version numbers).
Here is the context menu when I don't have the correct reference in place:
And here it is once I do:
This was SpecFlow.2.1.0 and VS2010 which led me to another issue with incompatible .Net versions so I ended up using SpecFlow.1.9.0.
Try to install SpecRun.SpecFlow from the Nuget Packages, after installation completes you'll get the "Generate Step Definitions" on the context menu.
It worked for me.
Install specflow from Extensions and updates and then restart the visual studio, clean and rebuild the solution
I had the same problem. maybe it was related with fresh IDE installation or maybe it was something new... here is just short note about this issue and possible solution:
At the beginning of IDE/project configuration check or install packages for SpecFlow in the NuGet manager.
Check twice what exactly you will use in the project Xunit or Nunit and then install the related package Xunit or Nunit. In my case, I was working with Xunit and install it.
After installation, you will see new items in the References
and pop about re-generation feature files
After that Generation steps will be available
This is because you may not have the simply installing the Extension for SpecFlow at Solution level is not enough.
SpecRun.SpecFlow is an evaluation version unless you are prepared to play for a license key.
I added the NuGet package SpecFlow.xUnit to the Unit test Project within my solution where I held my feature files. This resolved the issue, I now see Generate step definitions.
This is achieved by Right-clicking on your feature file in the code editor and select Generate Step Definitions from the popup menu. A dialogue is then displayed.
This happened to me when I migrated an existing project to a new PC.
Turns out I need to do: Visual Studio 2019 > Extensions > Manage Extensions > select 'Online' in the left hand nav > then search for 'Specflow' in the search box > then download it and close Visual Studio. It auto installs then.
Finally reopen VS and it should work.
In Visual studio 2022 the context menu item "generate step definitions" renamed to "Define steps" as per below specflow documentation.
https://docs.specflow.org/projects/specflow/en/latest/visualstudio/Generating-Skeleton-Code.html
I have a Continuous Integration Build Running on a BuildAgent which I can not get working properly. I recently changed our codebase to C# 6.0 and changed the projects to ToolsVersion 14.
I did install Visual Studio 2015 on the Build Server (TFS 2012). If I do now check in the C# 6.0 code the build fails on the first project ("$" is unexpected or something")
The BuildTemplate is "DefaultTemplate.11.1"
If I check the log files the build calls the wrong csc.exe (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe)
if I do start the MSBuild/14.0/Bin/MSBuild executable with the project without any switches the Build succeeds. Why does the TFS BuildAgent not use the ToolsVersion and how can I get TFS 2012 to build my Visual Studio 2015 solution
If I add the MSBuildArgument /tv:14.0 it still fails. As it calls th Version 12 of MSBuild which is part of the .NET 4.6 RC Framework which ships with Visual Studio 2015.
Changing the ToolsPath of the MSBuild Activity does get the Build working but spits bullets if I try to run my UnitTest. I get aMissing dlls "Microsoft.VisualStudio.TestPlatform.Utilities.dll" exception. (VS2012 is installed as well on the Build Server).
UPDATE:
I do now get a different error with my unit tests:
TF900548: An error occurred publishing the Visual Studio test results.
Details: 'Method not found:
'System.Collections.Generic.IEnumerable<System.String>
Microsoft.VisualStudio.TestPlatform.Utilities.InferSettingsHelper.MergeRunSettingsAndFindCompatibleSources(Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture
ByRef,
Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion
ByRef, System.String, System.String,
System.Collections.Generic.IDictionary`2<System.String,System.Collections.Generic.KeyValuePair`2<Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture,Microsoft.VisualStudio.TestPlatform.ObjectModel.FrameworkVersion>>,
System.Xml.XPath.IXPathNavigable, System.String ByRef)'.'
For those of us not living inside build templates every day here's the steps that got it working for me:
First find the template associated with your build (if you already know where to find it skip a couple steps).
Just right click the build definition and select Edit build definition
Select the Process tab and you'll see the name of the template (quite likely to be DefaultTemplate if you haven't customized it). On the far right click Show details to see the path for the template.
Go to the Home tab under Team explorer and click Source control explorer
Find the template file and double click to edit it. It should come up in a graphical view like this. Scroll till you find Run MSBuild for Project
Click on this item which will immediately bring up properties
Click on the little icon on the right - don't try and type it in because it'll probably explode and crash Visual Studio.
Enter IN QUOTES the following "C:\Program Files (x86)\MSBuild\14.0\bin"
NOW FOR THE MOST IMPORTANT PART
For me the Run MSBuild for Project was in TWO places.
So I just repeated the above steps in both places, and then after I checked in the .xaml file my build FINALLY worked fine.
You may need to recycle the agent / controller from within the TFS tool.
Edit template change msbuild activity ToolPath to "MSBuild/14.0/Bin/MSBuild"
See answer by Marson.
Using the TfvcTemplate.12.xaml build process template with the /tv:14.0 Build argument worked for me.
use msbuild aruguments /p:VisualStudioVersion=14.0
In my TFS 2010 build definition, I call MSBuild on my own custom my.targets MSBuild project. It does all the compilation, testing, etc. that I need. Its log file is specified, as is a log drop location, and the log appears properly in that place. However I can't see it in the TFS Build Summary report. The "View Log File" link is grayed out. It seemed to work when the project I was building was a ".sln" file. What magic voodoo is baked deep in to the heart of the common MSBuild files to make this log link work properly, and how can I reproduce it?
You may find your answer in these posts from Jason Prickett:
TFS2010 – Changing The Way Build Information IS Displayed
TFS2010 – Customizing the Build Details View – Summary View
Important to note is that the MSBuild Log File will only appear if you enabled inside the build definition to copy output to the Drop Folder. If that option is disabled, the link will not appear in the build log view.
I'm using ant as my primary builder for a flex project in IntelliJ. Every time I build, IntelliJ runs the code analysis tool and finds a bunch of errors in my build file, which pops up the "Messages" window every time. Actually, the errors that it finds are complaining mostly about properties which are defined in a separate file, which it doesn't actually parse when running the analysis.
Edit: Additionally, I am making use of ant tasks which generate properties on the fly, which IntelliJ is unaware of.
Is there any way to turn off file inspection for ant build files during the build process?
That sounds weird. IDEA on the fly inspections which you get while editing the build.xml file should not pop-up when you actually build the project unless they are really errors and are reported by Ant to IDEA while the build file is executed.
IDEA can perform additional validation and report errors on Make for certain components (see Settings | Compiler | Validation), but it doesn't include Ant build files and is not triggered when you just run the Ant target.
If you don't want to see warnings from the Ant Messages Window, you need to toggle off the "Show All Messages" button.
If you don't want IDEA to analyze your build.xml file for errors, click the Hector icon in the status bar and disable the inspections per file by changing the highlighting level from the Inspections to Syntax.
Clarify the problem if it's not the case (knowing IDEA version would be also useful).
Does the .properties file exist, and is it in your CLASSPATH? IntelliJ is very smart about figuring that stuff out. When IntelliJ complains, I usually assume that I'm making a mistake. That posture usually gets me to a solution pretty quickly.
You can disable Ant plugin altogether. IDEA becomes quite slow on large Ant builds, so found this to be of help:
Crtl+Alt+S (for settings) -> Plugins -> Ant Support (uncheck)