Visual Studio Control Recognition - visual-studio-2012

The original problem:
I would add a control in a .aspx web form file, save it, and the designer code would not be appropriately updated. Therefore, my code behind file could not find any of the variables I was telling it about.
Things I tried to do that didn't work:
Converting the aspx file to web form. Storing the text inside, but deleting the files in the solution and re-adding them, re-adding code. Closing and opening VS.
Thing I tried that did work:
Deleting the files in the solution and re-adding them. Readded text bit by bit.
Emperical cause of the problem was in code behind aspx.cs file:
private const string RECORDSPERPAGE = "RecordsPerPage";
At any point in time after the addition of this variable (seen in this block)...
public partial class RequestSearch : ProtectedPage
{
private const string TOTALPAGES = "TotalPages";
private const string CURRENTPAGEINDEX = "CurrentPageIndex";
private const string RECORDSPERPAGE = "RecordsPerPage";
...if a control was added in the aspx file, the designer code was not updated appropriately and the code behind could not recognize the subsequently added controls, which were similar to this one...
I changed the name of this string constant to RESULTSPERPAGE. Everything worked after that.
So my problem is solved, it seems, but I have no idea why. RECORDSPERPAGE is not declared anywhere but that file, not used anywhere but in an analogous way to the other private string constants shown that do not cause the designer generation problem.
Hoping someone will have knowledge of the magic of Visual Studio that is allowing this kind of behavior, or alert me to somewhere else I might look to understand better the underlying cause of the problem.

Related

Can I make sure resharper does not change the order of the fields in this class?

I'm using this NetResource class to send files to a network drive and it looks like this:
[StructLayout(LayoutKind.Sequential)]
public class NetResource
{
public ResourceScope Scope;
public ResourceType ResourceType;
public ResourceDisplayType DisplayType;
public int Usage;
public string LocalName;
public string RemoteName;
public string Comment;
public string Provider;
}
Now it's very important that the order of these fields stay the same, as hinted on by the StructLayout attribute.
However, when someone would run a resharper cleanup, resharper decides to move the fields around and that would break the code.
Is there any way of telling rehsarper to not mess with it? I feel like if I can't do that, someone is going to eventually break the code and have no idea where to look.
But a mediocre solution to that I think would be to create a unittest that can check if there layout is as expected.
Edit: I've seen this answer, but it is outdated and requires resharper settings to be updated. I will also not be guaranteed that coworkers use this resharper setting. I'm looking for a way to add it in the code, just like you can do // ReSharper disable once InconsistentNaming
I see a couple of solutions here:
You might mark the class with NoReorderAttribute from the JetBrains.Annotations (there are several ways to add them to a project). Then ReSharper will stop reordering members inside the marked code entity.
It is mostly about already mentioned answer, I will show you how to get the same things in last ReSharper builds. All you need is to add "System.Runtime.InteropServices.StructLayoutAttribute" to "Non-reorderable types" pattern in ReSharper | Options | Code Editing | C# | File Layout.
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
To make sure your colleagues use the same settings in ReSharper, save this change to the Solution team shared layer (Save To at the bottom of the Options dialog). Then if any of your colleagues opens the solution, ReSharper will automatically use the setting from this layer with no additional actions required.

Android Studio Can I save the javadoc comments to an external file

Is it possible to write javadoc comments in a seperate file.
My usual method for writing comments is like below
/**
*#param name person name
*/
private void testMethod(String name) {
//something to do...
}
Is it possible to move all these embedded comments to a external file(s) that i can reference.It should still show the popup on mouse-over.
No, this is not possible. The main idea behind Javadoc is to keep code and documentation together to increase the likelihood that they stay in sync.

Remove Default.css from Web Forms For Marketers in Sitecore

Is there a way to remove default.css and /colors/default.css from a page with a web form for marketers form on it using sitecore?
I have found a few places suggest simply deleting the file, but then it is still outputting redundant code. I don't want to simply delete the contents of the file for the same reason.
I have found the forms folder in sitecore with the standard values seemingly telling the form to import default.css, but if I change it to blank or even another file, default is still there and nothing else shows up.
You can open static method Sitecore.Forms.Core.Configuration.ThemeManager.RegisterCssScript in Sitecore.Forms.Core assembly via reflector. It seems that there is no simple way to remove adding this style reference.
You can remove this link in OnInit or OnLoad events handling as workaround.

Navigate between loosely related classes based on naming convention

In my current project we have many parts where we have something as follows:
var request = new ThingRequest {someId = };
ThingResponse response = dispatcher.Get<ThingResponse>(request);
Where dispatcher fetches a class with the name ThingRequestHandler that handles the actual logic.
public class ThingRequestHandler : RequestHandler<ThingRequest, ThingResponse>
This system is great for keeping it SOLID but I'm having trouble navigating easily.
Currently I use R# to goto class and -as I now the class name to follow convention- manually type the class name. This usually works but makes my head jump from thinking about the problem to thinking about a class name.
I would love to be able to navigate to my ThingRequestHandler from my dispatcher.Get line with one keystroke or click.
Is there a way Visual studio 2012, R# or any other plugin or macro would help me do this?
In R# 8+ they made a loads of improvements and especially to the navigation. They introduced CamelHumps which could be very useful in your case. For example you could navigate to ThingRequestHandler just by typing trh.

Loading embedded resource .rtf file into richtextbox on load C#

Ok so I read about loading an embedded rtf into a rich text box and I am trying to do it when the form loads. The form is not the main form, it is a second form that loads when a control is clicked. This is what I have on the form when it loads:
private void Credits_Load(object sender, EventArgs e)
{
Assembly creditAssm = Assembly.GetExecutingAssembly();
using (Stream creditStream =
creditAssm.GetManifestResourceStream("YDisplayView.credits.rtf"))
{
creditsRichTextBox.LoadFile(creditStream, RichTextBoxStreamType.RichText);
}
}
In the solution explorer the rtf file shows as a resource and the build action is set to embedded resource.
when I click the button to load the form, it shows as expected, but nothing happens. The contents of the rtf doesn't seem to show :/
I can only assume I am doing it wrong :(
Any help for this newbie would be appreciated.
I figured it out:
creditAssm.GetManifestResourceStream("YDisplayView.credits.rtf"))
needed to be:
creditAssm.GetManifestResourceStream("YDisplayView.Resources.credits.rtf"))
Edit: For some reason this time around I can't get the above code to work but I found another one that did so hopefully either/or will be of some help to new coders out there :)
string rtf = yourAppName.Properties.Resources.yourEmbeddedRTFName;
yourRichTextBox.Rtf = rtf;
I wanted to create an rtf help file named Help.rtf and have it stored as a resource and so it could be loaded when a Help form was loaded without having a Help.rtf hanging around the application folders.
I found I needed to add the rtf file to the resources through the menu's Project-> 'Your name space' Properties... then navigate to Resources tab, then Add Item etc etc... before the intellisense would offer the rtf file in it's drop-down list when I typed 'My.Resource.' Now, the list of resources including the Help file I added shows up (without extension, which is normal).
In short, once this was done, then the following worked:
RichTextBox1.rtf = My.Resources.Help
Apparently it wasn't enough just to Drag&Drop, Copy or even add the file using the 'Solution Explorer'!
Spent 3 days on this problem so I hope someone finds it usefull.

Resources