Resharper naming convention exception for specific word - resharper

Our customer has a terminology called A2b, not A2B, exactly A2b.
We want to have the same name in our source code.
However, Resharper always gives warnings and proposes to use A2B.
For example: We would like to have LoadA2bData, CheckA2bAvailability instead of LoadA2BData, CheckA2BAvailability.
Is there any workaround for this?
I saw this question Resharper Naming Exception for "iPhone". But it cannot be applied for our case because A2i is not only used as prefix or postfix, but also in the middle of the names.

You can change the regex off resharper 7 this means that you can enter a custom inspection regex. You can make a new naming style for your current project.

Related

How does lab.antlr.org get the parser rule and alternative number?

I have been playing with ANTLR Lab (really nice by the way) and was wondering how it is able to label the matching parser rule and alternative number. For example, below content:1, x_tag:2 and x_tag:3 are all rule names and the number after the colon is the alternative within that rule.
I have built a recognizer from my grammar but cannot see from looking at the runtime API how to access them from within a custom listener.
AFAIK, ANTLR Lab and the ANTLR IntelliJ plugin both use the RuleContextWithAltNum to set and get the alternative.
Note that it is only implemented in Java. From the documentation:
A handy class for use with options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} that provides a backing field / impl for the outer alternative number matched for an internal parse tree node. I'm only putting into Java runtime as I'm certain I'm the only one that will really every use this.
Also see the related stackoverflow Q&A: Is there a way to know which alternative rule ANTLR parser is currently in?

Finding all unassociated labels in the ASP.NET project

I'm undertaking a Section 508 upgrade/conversion/whatever, and one thing that would speed me up a lot is an easy TODO list. A large offender is that we have <asp:label> tags without the AssociatedControlID="" attribute set. How can I easily find all of these tags in my solution?
I'm using Visual Studio 2012 with ReSharper (can a custom pattern help?).
Yes, a custom pattern should be able to find those for you. Use ReSharper → Find → Search with Pattern, and set up the pattern something like:
<asp:label $attributes$ />
where the $attributes$ placeholder is an "attribute placeholder", with the option "Name should NOT match the regex" set to something like \bAssociatedControlID\b.

MFC ID_ vs IDM_ prefixes and their range

I have been working on cleaning an old project's resource.h.
In the project I am working on, I have some IDs which are in the form:
IDM_XXXX 32771
but are referred in code in ON_COMMAND and ON_UPDATE_COMMAND_UI statements.
So am I right in thinking that they are following the command architecture and ideally should be named as ID_XXX instead of IDM_XXXX?
I have read through TN022: Standard Commands Implementation and see that Microsoft says:
We recommend you use the standard "IDM_" prefix for menu items which
do not follow the command architecture and need menu-specific code to
enable and disable them.
I am not sure what is meant by menu-specific code here.
How are IDM_XXXX resources normally handled? Also what is the valid range range for IDM_XXXX? I have gone through TN020: ID Naming and Numbering Conventions but am confused.
ID_ and IDM_ are interchangeable because commands are accessible via command bars, menus or maybe ribbons. I never use IDM_, I only use ID_
Reserved by the MFC is 0xE000->0xEFFF and 0x7000->0x7FFF.
TN020 says that menu/command IDs must be in the range of 0x8000 and greater, but I found no reason why to do this. In the tooltip handling and command routing of the dialogs of the 16bit MFC version and AFAIK an old MFC4.x version, there was a specific code that looks for commands being greater than 0x8000.
By accident I had cases were an ID <0x8000 was created, but it worked.
I would resist not following the recommendations in the technical note. Microsoft does have undocumented messages that may interfere with your code if you violate their recommendations. And, debugging such an issue would be difficult. Additionally, following the recommendation allows you the extra benefit of...
following the MFC command architecture not only makes command handlers
more powerful (since they will work with toolbars) but makes the
command handler code reusable
This means MFC will use the same code to handle any menu and toolbar interactions that are linked together.

VS2010 modify intellisense popup order via an addin?

Is it possible to modify the order of the intellisense options shown when I hit ctrl-space?
Specifically, I'd like to order them in scope, so that if I have a variable in my function that matches what I've typed so far then it goes to the top of the list. If there's a member in the class, that's next, etc. I'm just kind of sick of having to type enough that I don't match some random global symbol in Windows' crypto libraries or whatever.
Is this kind of this possible? Where do I start? I looked for an obvious option in vs2010, but didn't find anything.
My programming language is native c++.
Here's what I've found so far.
A walkthrough showing how to add items to the intellisense popup: http://msdn.microsoft.com/en-us/library/ee372314.aspx
The walkthrough uses the ICompletionSession interface:
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.intellisense.icompletionsession.aspx
It looks as if you might be able to clear the CompletionSets, and replace them with your own completion sets, but I'm not sure if there's any way to change the order, or if they are always sorted. There is the IIntellisensePresenter interface, but it looks like it's pretty much empty.
Also, from the walkthrough, it looks like you can fill the CompletionSets with a dumb list of strings, so you'd need some other way of interrogating the symbols to determine scope, which may not always be possible.
In short: Probably not possible at the moment.

Can ReSharper automatically add missing references?

I just started using VS2008 and ReSharper.
I have a line:
Microsoft.Office.Server.Diagnostics.PortalLog.LogString("*** BOO Feature activating ***");
VS shows "Office" as red because it cannot resolve symbol "Office".
Can I make ReSharper just add the reference automatically, or do I need to manually surf to the reference and add it?
R# will not add the reference automatically but once you do it (manually) it will suggest the correct namespaces for you.
To get the best out of resharper in relation to referencing assemblies and adding using statements don't plan ahead. When coding don't put in any references our using statements just start typing the code:
public class MyClass
{
Foo foo = new Foo();
}
Initially "Foo" will be highlighted to indicate it cannot resolve the symbol, place your caret on "Foo" and either hit your short cut for the resharper hot fix (Alt + Enter) or click on the red light bulb.
If any of the other projects in your solution reference the assembly that contains "Foo" or it is in the core .net library you will get the option to "Reference '{Foo's Assembly}' and use '{Foo's namespace}.Foo'".
If your project already contains the reference you will get the option to use {Foo's namespace}.Foo.
If it cannot resolve the assembly you will need to add it the once but after that either option 1 or 2 will apply.
If you think about how large the framework is, plus any potential third party assemblies in the GAC...you start to see why when a type's not found Resharper looking through them all for it is a really bad idea for performance.
A typo would leave you with a coffee break while it looks. Also, what if it did find the type, nothing says 2 third party assemblies couldn't define it, or 2 or more versions of that assembly in the GAC, etc.
It's better to leave the decision up to you to reference exactly what you want, and that's what it does, for performance and explicitness.

Resources