visual studio resources paste column - visual-studio-2010

I'm using the resource editor in visual studio. I'm trying to copy the values from the value column of one resource file and paste them in the comment column of another resource file.
I've tried using SHIFT+ALT which copies the column correctly, but then the paste doesn't work as expected (instead of pasting in the comment col. , new keys are generated)
Is this possible? If so how?

Since paste wasn't working in the visual studio resource editor, I pasted the values column data in a google docs spreadsheet and that worked.

Related

What causes "O/R Designer validation failed" after minor changes to a .dbml file using Designer?

I added some columns to a table using SQL Server Management Studio, and then wanted to reference them in my project in Visual Studio 2010, where it is loaded using Entity Frameworks, which seems not to have a handy feature for simply importing updates from the database.
So I manually added the columns. They were just bit columns like an existing column, so I used cut and paste to duplicate that column, then renamed them and filled in the Storage field to match.
But then when trying to build the project, it would fail with:
O/R Designer validation failed . . . myDB.dbml Error: The operation could not be completed. Unspecified error
The main tips I found about these not-very-helpful error messages, involved restarting Visual Studio. That didn't help me here.
What else can cause (and what can fix) this error?
What caused this in my case, was an apparent bug in Visual Studio 2010's visual DBML editor!
That is, the new columns I had added and manually entered correctly, did not get saved correctly. This was somehow invisible even when closing Visual Studio and reloading the editor - there, it appeared correctly.
However, when I looked at the actual .dbml file using Notepad++, I could see that the Storage= values were all still the same as the column I had Cut & Paste from, rather than the correct values I had hand-entered, and that showed in the visual DBML editor!
I notice that the correct columns do not even have a Storage= field, which is probably a clue to what the bug in the editor is.
I deleted the incorrect Storage= fields from the .dbml file using Notepad++, and this solved the build problem.
I also needed to go into the visual designer and just make a random trivial change (I nudged the position of the table in the display) before it would add member variables for the columns I had added, to the auto-generated LINQ .cs file.

Some Visual Studio files are linted differently based on how they were created, even if they end up the exact same. Why?

For example, I can create a test1.xml file, put in my code, then save it as test1.proj. It has the xml coloring/linting I want. If I create a test2.txt file, insert my code, then save it as test2.proj, it will not have any of the coloring/linting I want. In the properties and everything I can see, they are the same file, but Visual Studio treats them differently. Why? Is there a hidden property I can edit?

Visual Studio - Remove unused files

Was wondering if there's an extension or macro or something that looks through your solution and gives out a report of which js/css/image files are not being referenced anywhere in code?
I have a large project and over time it has accumulated dust. Other than manually searching for each file's usage, is there any other time saving way?
There's a Visual Studio Extension that searches for unreferenced image files. It finds all image files in your project and then scan all aspx/cs/ashx/css/js files for references. It has not yet been updated for Visual Studio 2012.
http://visualstudiogallery.msdn.microsoft.com/fb7a9b9c-08e1-4bb4-91b4-8e512feb5a1b
Update You will not find a tool that can systematically identify unused resources, because JavaScript, CSS, and image files can be loaded dynamically. This article shows how to load JavaScript and CSS dynamically, and it's a straightforward task in JavaScript to load an image dynamically. It's easy to imagine a scenario in which the image name is loaded from an external data source, or concatenated from another field value plus ".jpg". Clearly any tool that attempted to scan your source to find unreferenced files would miss these resources.
That said, you can search for hard-coded references to .js, .css, and .jpg files using Visual Studio's search by regular expression feature, or by using a high-powered text editor like Notepad++ with a Regular Expression search feature.
For example, to use Visual Studio to search for all files ending in .js that are referenced in ASCX ir ASPX pages, go to Edit/Find and Replace/Find in Files, set the search expression to .js> switch on
"Use Regular Expressions", and set "Look in these file types" to "*.aspx; *.ascx".
("\" escapes the ".", and ">" means end of word, so that "foo.js" is found, but not "foo.jsx". Visual Studio has its own Regular Expression syntax, which is documented here)
In addition, the tools in my original response below can give a good picture of what JS/CSS/IMAGE resources are actually getting used when your site is loaded. When used in conjunction with a testing tool like Selenium, these should allow you to remove resources with confidence.
There are several tools you should look at:
WARI--Web Application Resource Inspector seems the closest fit. According to their website:
WARI scans your web application and examines dependencies between JavaScript functions, CSS styles, HTML tags and images.
The goal is to find unused images as well as unused and duplicated JavaScript functions and CSS styles.
JSCoverage is a code coverage inspector for Javascript.
For CSS, there is an online tool at http://unused-css.com/ and a Firefox extension called DustMeSelectors
The extension in the selected answer above only works in vs2012 while Code Maid works in vs2010 - vs2014:
There is a free extension called Code Maid that "is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding." Does images as well.
Solution Features
is semi - manual
isn't an extension
looks long but is not complicated or difficult
works for just images or all files
overcomes all the ajax tricks
should work with any project or version of Visual Studio
Steps
Run the website in Chrome with debugging turned on (press F12 before launching website)
Completely exercise the website. Make it download everything that it will ever download.
Go to the Network tab.
On the file grid, Click on any of the images that appear in the list (doesn't matter which one). This will make all column headers but Name go away.
Click on the Name column header, to sort ascending.
Do CTRL+A, CTRL+C to copy all file names.
Paste into a new Google spreadsheet (in google docs) into cell A2.
Repeat steps 6 and 7 if for any reason it didn't copy all the file names. Scroll down.
Go into your actual website images directory (or whatever directory you are interested in comparing) in a command prompt and issue dir /b. Copy this into the clipboard (mark function) and paste into cell B2.
In cell C2, paste this formula =not(isna(VLOOKUP(B2,$A$2:$A$TheBottomOfA,1,false))). Alter TheBottomOfA to be the last used row in column A.
Copy the formula down for all your values in column B.
In cell C1, type Is Used. In cell B1, type Name. Add a data filter on all the values in columns B and C. Set the filter with the mouse in C1 to show only Is Used=FALSE.
Result
What you're looking at in Column B is a list of files you are not using.
Note
I recommend moving the unused files to an offline folder instead of deleting them.
Warning
You still need to use common sense. BRAIN=ON
2022 solution
you can use this extension in vscode to find all unused exports
If you're using a new version of Visual Studio and can't use the extensions, what I did was this:
Exclude all target files.
Find ",,," (this indicates an absolute resource reference) and include each resource found. Note, you should try any unique keywords relevant to your references.
Repeat step 2 until Visual Studio stops opening files (if no new matches are found, already opened documents will come into focus).
Try building project. If you happen to miss a resource, Visual Studio will let you know. In that case, repeat steps 2-4; it is worth nothing this will rarely ever be necessary.
I've only had to do this once and I spent ten minutes, at most.

How to associate a Resx file to a class in Visual Studio 2010

How do I associate/"bind" an resx file to a class file in Visual Studio?
For example, when a new windows form is created, an resx file is automatically associated with it.
I am asking this as the following code doesn't open the right resource file for another .cs file I have:
ComponentResourceManager manager = new ComponentResourceManager(typeof(MyClass));
This code works fine for frmLogin from above however.
The MSDN documentation for the constructor:
Creates a ComponentResourceManager
that looks up resources in satellite
assemblies based on information from
the specified Type.
That a form has an associated .resx file is an implementation detail that's specific to forms. You cannot otherwise associate an arbitrary class with a .resx file. I assume that you actually want to use a ResourceManager here.
Do note that there's one already built-in through Properties.Resources, giving you access to resources that you added to Project + Properties, Resources tab.
Should you have lost this indenting by adding existing files to a project, you can restore the indenting for files, though I have not tried it for all file types, by using the 'DependentUpon' node in the project file.
The technique is described in more detail at Code rant: Nested files with 'DependentUpon' in Visual Studio
I found an existing answer on SO since discovering the article above, but as the question is formulated so differently I'm keeping this answer in place.

How does one copy a dialog resource from one project to another in Visual Studio 6.0 or Embedded VC++ (eVC)?

I've got two branches of code. 1 has a dialog box that the other doesn't, but because of politics the dialog box wasn't moved into the newest branch. Now they want it in...
So is it possible to copy a dialog box from one project to another.
There apears to be an export and import feature however it's greyed out.
.RC files are simple text files. You can simply copy/paste the DIALOG text from one .RC file to the other. Make sure that you copy the corresponding RESOURCE.H entries as well.
Alternatively, you might be able to open both .RC files and then simply drag-and-drop the dialog from one to the other.
Update for Visual Studio 2010 - 2013:
You can still drag-drop and copy-paste, but only outside of your project / solution.
Close solution, open both RC as files without any open solution, and go. For drag, "Hold down the CTRL key and drag the resource to the second .rc file. For example, drag IDD_DIALOG1 from Source1.rc to Source2.rc."
Microsoft - How to Copy Resources
Drag and drop doesn't work in Visual Studio 2010. Editing the .RC file does work but be careful. For me the ID for the dialog showed up with *ID_etc*. I copied it and removed the *'s and it seemed to fix the problem.
I finally figure it out how to copy a Dialog from one solution to another.
Steps:
Open both solutions in separte windows.
Add a new Blank Dialog -Add Resources-> add->newDialog
Open Both Dialogs Open Binary data.
Copy the Binary data from source solution dialog to Destination Dialog
This is just to add some visual detail to the accepted answer (by Roger Lipscombe) along with its steps.
In order to copy a resource such as a Dialog from one project another project, below steps can be followed.
Start a new instance of Visual Studio.
Open both source and destination .RC file as files, as shown in the picture.
From the source RC file, copy required dialog.
Switch to the destination RC file tab and simply paste it.
Please note that this operation would have updated the resource.h file. That is an excellent help by Visual Studio.
One will have to make sure that no duplicate resource IDs are present in the resource.h file. When working with some legacy projects, it is found that there came some duplicate resource Ids that had to be manually corrected. It looks like such an effort is worth considering the mammoth task required otherwise.

Resources