Visual Studio 2010 Pro - SuppressMessage - visual-studio-2010

Is the option to SupressMessage not available in VS 2010 Pro?
When I right click on the warning in the warning list there is no option to suppress. I also tried it with errors and there was no option. I then tried to create my own GlobalSuppression.cs file but have no idea what category the warning should be classified under.
Right now I'm doing this, which works, but I would prefer to use a GlobalSuppression file
#pragma warning disable 0649,0169
[Import(AllowRecomposition = false)]
private IModuleManager _moduleManager;
[Import(AllowRecomposition = false)]
private IRegionManager _regionManager;
[Import(AllowRecomposition = false)]
private IRibbonService _menuService;
#pragma warning restore 0649,0169
These are the warnings from the output window that I want to suppress:
warning CS0649: Field 'Shell._moduleManager' is never assigned to, and will always have its default value null
warning CS0169: The field 'Shell._regionManager' is never used
warning CS0649: Field 'Shell._menuService' is never assigned to, and will always have its default value null
The reason why I want to suppress is that my solution uses Prism / MEF so those variables are assigned at runtime.

The CSxxxx warnings you are seeing are C# compiler warnings, not FxCop/Code Analysis warnings. They must be suppressed using #pragma warning disable directives, not SuppressMessage attributes.
Incidentally, integrated Code Analysis is only availabe in Premium or Ultimate, not Pro.

Related

Visual Studio Intellisense describing the property/method not working

I was using Visual Studio 2012 and it used to give the description of a property/method, which doesn't seem to work in VS2019. Is there an option that I will have to enable for this to work?
Below screesnhot is an example of File Input/Output operation:
When I scroll/hover over ios::app, it should give a description "Append to the end of the file" which it does not.
Second concern is that it is giving me a lot of other options as well (marked as * in VS). Is there an option to disable that permanently?
Final concern is that, when I hover over a function, it will display the parameters that the function is expecting (Or list of suggestions if the function is overloaded). But for some reason, in the below case, it is displaying along with namespace. Is there an option to disable that?
public static constexpr std::_losb::_Openmode std::_losb::app = (std::_losb::_Openmode)8

Visual Studio debugger - Displaying integer values in Binary

I'm using Visual Studio 2017 and I need to look at the binary representation of integer variables.
How can this be achieved from the Visual Studio debugger?
Type 'var, b' in the watch, for example:
According to the Visual Studio debugger documentation:
You can change the format in which a value is displayed in the Watch, Autos, and Locals windows by using format specifiers.
This note on debugging engine updates and compatibility is also worth noting:
When the Visual Studio native debugger changed to a new debugging engine, some new format specifiers were added and some old ones were removed. The older debugger is still used when you do interop (mixed native and managed) debugging with C++/CLI.
Although it mentions it can be applied to Autos and Locals windows, it is unclear how it is done as the variable names cannot be edited in those windows.
A <variable>, <format> syntax may be used in Watch and Immediate windows, like so:
Here is a direct link to the complete list of format specifiers.
Right-click the value it’ll show a menu list, but it only give us the option of Hexadecimal Display.
To display the variable with binary value in watch window, I suggest you write function to covert it :
The function that in my code is:
public static string ToBinaryString(uint num)
{
return Convert.ToString(num, 2).PadLeft(32, '0');
}

Custom ColorableItems in Visual Studio Extension

I am working on a LanguageService for Visual Studio and am having issues with custom colors in Visual Studio 2013. I recently moved from Visual Studio 2010 to 2013, and now whenever I set RequestStockColors to false, I lose all syntax highlighting.
My LanguageService implements GetColorableItem and GetItemCount. I am using 9 custom colors. When I debug my language service, I have noticed that GetColorableItem is called a handful of times, but GetItemCount never gets hit.
I am using the following command-line arguments when I debug through Visual Studio:
/ranu /rootsuffix Exp
Update: I changed the name of the first 5 colors (the ones that overlap with the standard token colors) to match the standard names (e.g. "Keyword", "Identifier", etc.) and those colors now show, but none of my extra color types show up. In addition, I never see any of them appear in the Fonts and Colors configuration in Visual Studio. How do I get them to be installed there?
I recently ran into a similar issue where my custom ColorableItems weren't showing up in my syntax highlighting. I was able fix this by clearing the font and color cache.
I temporarily included the following in my Initialize method of my vs package:
IVsFontAndColorCacheManager mgr = this.GetService(typeof(SVsFontAndColorCacheManager)) as IVsFontAndColorCacheManager;
mgr.ClearAllCaches();
This fixed things for me. This fix shouldn't require including the 6 default values or require any additional ClassificationFormatDefinition classes.
NOTE: Worth mentioning that I also never see GetItemCount() called, but clearing the cache fixed the primary issue.
Credit: Also some credit to a comment by Ed Dore on this thread http://www.databaseforum.info/8/1217583.aspx that helped me find my fix.
It turns out I needed to create an instance of ClassificationFormatDefinition for each of my custom colors and export them as a EditorFormatDefinition type. Once I did this, they showed up in the Fonts and Colors page and also showed up in syntax highlighting.
For each color beyond the default 6, I added a class definition as follows:
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "<name of color>")]
[Name("<name of color>")]
[UserVisible(true)]
[Order(Before = Priority.Default)]
internal sealed class ExampleColor: ClassificationFormatDefinition
{
public ExampleColor()
{
this.DisplayName = "<name of color>";
this.ForegroundColor = System.Windows.Media.Color.FromArgb(0, 0, 128, 128);
}
}
I am still seeing no hits on my GetItemCount() method, however.

Visual Studio Extension for Custom Memory Window

My custom tool window in a Visual Studio Extension package is supposed to evaluate custom expressions during debug sessions for VS2012 and VS2013. The final goal is to build a graphical watch window. Therefore, I must fetch the value of the expression result from the debug engine.
The evaluation works fine via
IDebugStackFrame2 -> IDebugExpressionContext2 -> ParseText
IDebugExpression2 -> EvaluateSync -> IDebugProperty2
The first problem here: On Visual Studio 2013 ParseText() does not correctly report errors. But the IDebugProperty2 retrieved is valid (for valid expressions). On VS2012 I get proper errors for invalid expressions.
This is where the real problem starts. The result Property2 represents a complex custom object. In order to visualize it, a specific property from one of its base classes needs to get retrieved. In my current attempt, I am using IDebugProperty2.EnumChildren() to walk along its members up to the right place in the class hierarchy, similar as one would do in the Locals window in Visual Studio:
[result] -> base -> Raw -> base -> Non-public Members -> [private field] ... a.s.o.
This is somehow working but introduces the following problems:
Problem 1: Get an internal member of some complex object
The members and their order received from EnumChildren() seem to depend on some factors, which are not obvious to me:
* Does the object has a Debug Visualizer attached? (VS2013 ignores enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE_RAW in EnumChildren and gives back the beautified version + a "Raw View" node, VS2012 works as expected)
* Is a 'Non-public Members' node shown? Sometimes it is, sometimes not - dunno from what it depends on
* Setting of 'Just my code' (? I read about it in several posts but couldn't really figure out a reliable rule)
* ... there must be other dependencies ?
This turns out to be a really hacky way of aquiring an internal member of some complex expression result object. What could be a better way? Using IDebugProperty3 and some Debugger Visualizer tricks? Any pointer would be great.
Problem 2: VS2012 fails to give memory bytes
Once I have the private member of the result object, I use IDebugProperty2.GetMemoryBytes() in order to 'serialize' its value (a plain System.Array) and transfer it to my Custom Tool Window. While this is working in VS2013, in VS2012 IDebugProperty2.GetMemoryBytes() always returns VS_Constants.S_FALSE. I am really out of ideas here. Since there is a Memory Window in VS2012, there ought to be some way to get this working here also? What am I missing?
The code used to query the memory API:
IDebugMemoryContext2 memCtx = null;
IDebugMemoryBytes2 memBytes = null;
// getting the memory context is working ok
if (tmpProperty2.GetMemoryContext(out memCtx) == VSConstants.S_OK
// VS2012 fails here, always returns S_FALSE, memBytes remains null:
&& (tmpProperty2.GetMemoryBytes(out memBytes) == VSConstants.S_OK)) {
...
Some more context:
OS: Windows 8 and 8.1
Visual Studio: 2012 / 2013
Tool Window built with MPF (C#) in VS2013, (removed all vers. 12 references from the package before deploying to VS2012)
Debug engines: C# and Visual Basic

having resharper give errors for all unused parameters except on events

we want to have resharper complain and show errors every time we have a unused parameter to make sure the developers keep code clean and remove stuff that is not being used
the one area where this falls over is events, because we have a lot of case where you are not using the sender object in the basic pattern.
(object sender, EventArgs args)
is there anyway to have resharper complain on everything EXCEPT event handlers?
As far as I remember inspection severity of 'Unused parameter' is set to warning by default, however you can change this to Error in Resharper>Options>Inspection Severity>Redundancies in Symbol Declarations>Unused Parameter.
When you start solution wide analysis, these are shown as error.
ReSharper is smart enough not to complain about sender parameter because it is part of the event signature.
I have tried this using ReSharper 5 EAP, so options can have different names in the previous version.

Resources