code-analysis

Find code that depends on .NET 3.5 SP1

白昼怎懂夜的黑 提交于 2019-12-07 19:01:35
问题 Is there a way to run some sort of code analysis to find code which will compile with .NET 3.5 SP1 but not 3.5 RTM? FxCop works for assemblies introduced with SP1, but for code that simply calls new methods and properties it does not detect that usage. 回答1: Sure, you can highlight this stuff with fxcop or VS team system. Make sure you have a read this answer. There is a bug with the current rules that ship with fxcop, so you need to do a bit of hand holding to get it to work. 来源: https:/

How to disable code analysis in MSBuild target ClCompile?

跟風遠走 提交于 2019-12-07 15:05:04
问题 When I build my projects via MSBuilds scripts, I obtain the following message during the work of ClCompile target: Running Code Analysis for C/C++… Output of MSBuild looks like: ClCompile: .... Source1.cpp Source2.cpp Running Code Analysis for C/C++… After changing <RunCodeAnalysis> property in build scripts to false: <PropertyGroup> <RunCodeAnalysis>false</RunCodeAnalysis> </PropertyGroup> this just disabled running RunCodeAnalysis MSBuild target, but it does not affect running code analysis

How to exclude a directory from the code analysis?

余生长醉 提交于 2019-12-07 14:50:08
问题 There have been some questions about this, but none of them solves my problem. I use SonarQube to do code analysis on one of my projects, which contain a Migrations directory. I would like to exclude all the source files in that directory from the code analysis. In the projects Configuration->Settings->Exclusions->Files->Source Files Exclusions I added "**/Migrations/ . " , but in the analysis results I still get issues in code files in that directory. The directory structure of my project

Remove rule sets from “Add or Remove Rule Sets”

限于喜欢 提交于 2019-12-07 12:41:24
问题 After experimenting with loading and unloading rule sets into C# via Nuget, my "Add or Remove Rule Sets" window has a bunch of rule sets from other solutions that I don't use anywhere, let alone in my current project: Is there a way to remove items from this list? 回答1: You should be able to remove the unwanted items by editing the following registry value: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\CodeAnalysis\RuleSetMRUList 来源: https://stackoverflow.com/questions/37392321/remove

C# CA2104 - Automated Code Analysis dislikes static readonly mutable types

血红的双手。 提交于 2019-12-07 11:27:49
问题 I've got a code like this: public abstract class Base { // is going to be used in deriving classes // let's assume foo is threadsafe protected static readonly Foo StaticFoo = new Foo(); } Visual Studio 2008's Code Analysis pops up this message: CA2104 : Microsoft.Security : Remove the read-only designation from 'Base.StaticFoo' or change the field to one that is an immutable reference type. If the reference type 'Foo' is, in fact, immutable, exclude this message. Is my design instrinsically

How to change Application Not Responding (ANR) Timeout in AOSP [closed]

最后都变了- 提交于 2019-12-07 06:43:01
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . How do I change the Application Not Responding (ANR) timeout in the AOSP source code? The default timeout is 5 seconds, but where is that set and how do I change it? 回答1: The ANR Timeout is defined in File InputDispatcher.cpp (frameworks\base\libs\ui) . Copying and pasting that piece of code below.

Class dependency graph with doxygen

≡放荡痞女 提交于 2019-12-07 06:31:48
问题 I want to generate a class dependency graph for a large project in C++. I'm trying to do it with doxygen. Here is the sample code: class Used { public: void bar(); }; class Base { }; class Derived : public Base { public: void foo(Used*); // Dependency on class Used }; Here is the collaboration diagram generated by doxygen: Nice, but Derived depends on Used through the method foo , and I want to see this on the diagram, like this: Unfortunately, doxygen generates such dependency only if Used

Visual Studio 2015 Code Analysis C6386 warns of buffer overrun

会有一股神秘感。 提交于 2019-12-07 06:11:09
问题 I've read a lot about the Visual Studio Code Analysis warning C8386, but can't figure out this particular issue with my code. I've reduced it to the following small program: unsigned int nNumItems = 0; int main() { int *nWords=nullptr; unsigned int nTotal; nTotal = 3 + 2 * nNumItems; nWords = new int[nTotal]; nWords[0] = 1; nWords[1] = 2; // this is line 18, warning C6386 delete[] nWords; return 0; } Analyze->Run Code Analysis->On Solution will give the following warning: file.cpp(18):

set default value in class constructor C#

戏子无情 提交于 2019-12-07 06:10:51
问题 I need a default value set and many different pages access and update..initially can I set the default value in the class constructor like this? What is the proper way to do this in C# .NET? public class ProfitVals { private static double _hiprofit; public static Double HiProfit { get { return _hiprofit; } set { _hiprofit = value; } } // assign default value HiProfit = 0.09; } 回答1: You can put it in the declaration: private static double _hiprofit = 0.09; Or if it's a more complicated

Using an AdHocWorkspace results in “The language 'C#' is not supported.”

被刻印的时光 ゝ 提交于 2019-12-07 05:39:00
问题 Using the RC2 of Microsoft.CodeAnalysis.CSharp.Workspaces in VS2015, this code throws an exception: var tree = CSharpSyntaxTree.ParseText(...); var workspace = new AdhocWorkspace(); var newRoot = Simplifier.Expand(tree.GetRoot(), compilation.GetSemanticModel(tree, false), workspace, n => true, true, CancellationToken.None); The exception message is "The language 'C#' is not supported." What am I missing to make this work? 回答1: You need to add a reference to the C# Workspaces NuGet package.