code-analysis

Windows Phone 8: Monitoring memory usage in mixed C#/C++

故事扮演 提交于 2019-12-08 18:51:03
问题 I want to monitor memory usage of a mixed C#/C++ app on Windows Phone 8 which uses Windows Phone Runtime Components. The problem is that when openening the analysis toolkit in Visual Studio (ALT+F1) I have only the option "Execution" (http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202934%28v=vs.105%29.aspx). For "pure" C# project the memory options are available as well. Are there other more or less easy means to monitor memory usage? Regards, 回答1: Have you considered building

Why does this method cause Code Analysis error CA2000: Call Dispose()

久未见 提交于 2019-12-08 17:45:31
问题 I'm building my project with the "Microsoft Minimal Rules" code analysis set and it gives me CA2000 on this method: private Timer InitializeTimer(double intervalInSeconds) { Timer timer = null; try { timer = new Timer { Interval = intervalInSeconds * 1000, Enabled = true }; timer.Elapsed += timer_Elapsed; timer.Start(); } catch { if (timer != null) { timer.Dispose(); } } return timer; } This method just creates a new System.Timers.Timer from an interval in seconds. I have three such timers

Can I suppress FX Cop code analysis violations globally?

久未见 提交于 2019-12-08 16:19:07
问题 When you use Visual Studio's code analysic (FxCop), and want to suppress a message there are 3 options. Suppress a violation in code. Suppress a violation in a GlobalSupression.cs file. Disable the violation check in the project file (via Project -> Properties -> Code Analysic). The later is very hard to review when checking in to Source Control, and it is hard to get an overview of all disabled violations. So we would like to use option 2. The problem with option 1 and 2 is that you get one

Use code analysis with Visual Studio DNX project (.xproj)

拈花ヽ惹草 提交于 2019-12-08 16:03:15
问题 Within the properties of an "ordinary" Visual Studio project (.csproj) it's possible to say Enable Code Analysis on Build (formerly known as FxCop). Since I've started playing around with new DNX projects (.xproj) I'm searching for something similar. I know there may be no build output, so the old approach may not really fit into this, but I'm quite sure the Code Analysis / FxCop rules still apply. Furthermore there should be some way to register a custom rule set (.ruleset) file within the

Why does the halting problem make it impossible for software to determine the time complexity of an algorithm

泪湿孤枕 提交于 2019-12-08 07:39:44
问题 I've read some articles about big-Oh calculation and the halting problem. Obviously it's not possible for ALL algoritms to say if they ever are going to stop, for example: while(System.in.readline()){ } However, what would be the big-Oh of such a program? I think it's not defined, for the same reason it's not possible to say if it's ever going to halt. You don't know that. So... There are some possible algorithms, where you cannot say if it's ever going to halt. But if you can't say the, the

“CA2000: Dispose object before losing scope” building Unity container

两盒软妹~` 提交于 2019-12-08 04:36:20
问题 I am using following code where I am getting fxCop voilation CA2000: Dispose object before losing scope: private static IUnityContainer BuildContainer() { var container = new UnityContainer().LoadConfiguration(); return container; } to remove this violation I have used following code: private static IUntyContainer BuildContainer() { using(var container = new UnityContainer()) { return container.LoadConfiguration(); } } But this code start throwing exception while resolving dependencies. Can

In Visual Studio 2013 how do I limit code analysis to my code and not to referenced assemblies?

淺唱寂寞╮ 提交于 2019-12-08 02:11:24
问题 I have a solution in Visual Studio 2013 (c# code) that has a reference to a third-party assembly that I added with NuGet (ICSharpCode.SharpZipLib). When I run the "Code Analysis" on the solution I get lots of warnings coming from the third-party assembly. How do I tell VS that I only want code analysis advice from my code? I'm pretty sure the errors are coming from the library itself and not my usage of it. There are a total of 32 issues e.g. CA2237: Mark ISerializable types with

Tool to detect missing disposes

落爺英雄遲暮 提交于 2019-12-08 01:01:40
问题 im searching for any tool that can detect any missing dispose calls on classes that do data access and file operations. And if it checks another performance issues it will be nice. BTW, i need to run the tool over the code, not on the execution. Thanks! 回答1: DevExpress CodeRush does this for you: see this article: Code Issues – Undisposed local Code Rush home: DevExpress CodeRush I have used the express version of this tool and personally I like it more than ReSharper. 回答2: The open-source

Is it possible to have Code Analysis warnings formatted like normal ones?

淺唱寂寞╮ 提交于 2019-12-07 22:01:09
问题 I like the code analysis included in VS2012. But it's a bit annoying that the warnings are only processable in the Code Analysis window, and not by stepping through the build output with F4 . Is there a way to overcome this limitation? How could I format the output of the static code analysis like normal compiler output (i.e. don't only print the filename but the correct path to the file being inspected)? I'm not using FxCop since I'm working with unmanaged code. 回答1: For unmanaged code

Finding property usage counts with reflection

佐手、 提交于 2019-12-07 19:39:36
问题 I have a generated file with around 10,000 public static properties and methods. I suspect that a nontrivial number of them are entirely unused, but there are around 50 assemblies and millions of lines of code to check to be sure. What I would like to do is run some kind of utility that can look into all of the compiled assemblies we have and tell me exactly which members of this class are being called, and give me counts for each one. Is such a thing possible with reflection, or do I need to