How to configure Visual Studio so I won't have to manually rename my source files
-
Okay what I've been noticing is that when I create a project in Visual C# and I'm writing my code in the editor, when I look over to the right by default Visual Studio calls every one of my source files Program.cs. So what I've been doing is which each project I'm working I go over to the right and left-click on the source file and rename it usually the same name as the class (like Java forces you to). But the problem with this is that it's still easy to forget to rename my source file and then I get Program.cs as the name of the file which I don't want. So how can I create my projects so when I start a new project somewhere Visual Studio will ask me straight off what I want the name of my source file to be. That way I won't have to rename it later.
-
Okay what I've been noticing is that when I create a project in Visual C# and I'm writing my code in the editor, when I look over to the right by default Visual Studio calls every one of my source files Program.cs. So what I've been doing is which each project I'm working I go over to the right and left-click on the source file and rename it usually the same name as the class (like Java forces you to). But the problem with this is that it's still easy to forget to rename my source file and then I get Program.cs as the name of the file which I don't want. So how can I create my projects so when I start a new project somewhere Visual Studio will ask me straight off what I want the name of my source file to be. That way I won't have to rename it later.
There's no inbuilt way to accomplish this. The default templates that are applied to VS have default filenames in them.
This space for rent
-
There's no inbuilt way to accomplish this. The default templates that are applied to VS have default filenames in them.
This space for rent
There should be a way to do it. I mean specifically how to start a project and have a text box show up during the creating and naming of the project so I can enter the name of my source code file there. I'm not asking Visual Studio to have esp or anything. But it seems to me that a guy should be able to "pre name" his source code file before you go into the editor and start writing code.
-
There should be a way to do it. I mean specifically how to start a project and have a text box show up during the creating and naming of the project so I can enter the name of my source code file there. I'm not asking Visual Studio to have esp or anything. But it seems to me that a guy should be able to "pre name" his source code file before you go into the editor and start writing code.
Add it as a suggestion to Visual Studio VNext.
This space for rent
-
There should be a way to do it. I mean specifically how to start a project and have a text box show up during the creating and naming of the project so I can enter the name of my source code file there. I'm not asking Visual Studio to have esp or anything. But it seems to me that a guy should be able to "pre name" his source code file before you go into the editor and start writing code.
-
Okay what I've been noticing is that when I create a project in Visual C# and I'm writing my code in the editor, when I look over to the right by default Visual Studio calls every one of my source files Program.cs. So what I've been doing is which each project I'm working I go over to the right and left-click on the source file and rename it usually the same name as the class (like Java forces you to). But the problem with this is that it's still easy to forget to rename my source file and then I get Program.cs as the name of the file which I don't want. So how can I create my projects so when I start a new project somewhere Visual Studio will ask me straight off what I want the name of my source file to be. That way I won't have to rename it later.
Member 12974235 wrote:
Okay what I've been noticing is that when I create a project in Visual C# and I'm writing my code in the editor, when I look over to the right by default Visual Studio calls every one of my source files Program.cs.
Not "every one". Feel free to create your own template; Create Your Own Project Template for Visual Studio 2013 and 2015 | DotNetCurry[^] :thumbsup:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)
-
Okay what I've been noticing is that when I create a project in Visual C# and I'm writing my code in the editor, when I look over to the right by default Visual Studio calls every one of my source files Program.cs. So what I've been doing is which each project I'm working I go over to the right and left-click on the source file and rename it usually the same name as the class (like Java forces you to). But the problem with this is that it's still easy to forget to rename my source file and then I get Program.cs as the name of the file which I don't want. So how can I create my projects so when I start a new project somewhere Visual Studio will ask me straight off what I want the name of my source file to be. That way I won't have to rename it later.
Member 12974235 wrote:
by default Visual Studio calls every one of my source files Program.cs
No, it doesn't. You only get the Program.cs file and its boilerplate code when you create a new Windows Forms or Console project. Class library projects don't get a Program.cs file at all and Class Library is the most heavily used project template. Well, at least for me it is. As for renaming the Program.cs file, I just about never change it. That's the most recognizable piece of a project easily identifying the entry point of the app in Solution Explorer, just like the Main method in a C/C++ app.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
Member 12974235 wrote:
by default Visual Studio calls every one of my source files Program.cs
No, it doesn't. You only get the Program.cs file and its boilerplate code when you create a new Windows Forms or Console project. Class library projects don't get a Program.cs file at all and Class Library is the most heavily used project template. Well, at least for me it is. As for renaming the Program.cs file, I just about never change it. That's the most recognizable piece of a project easily identifying the entry point of the app in Solution Explorer, just like the Main method in a C/C++ app.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave KreskowiakNothing wrong with my question. Rather giving polite answers free from sarcasm is a skill. This is one of the reason the Internet sucks so bad.
-
Nothing wrong with my question. Rather giving polite answers free from sarcasm is a skill. This is one of the reason the Internet sucks so bad.
Ummm... would you like to point out the sarcasm in my post? I just don't see it, and from the votes on our posts, it seems nobody else does either.
System.ItDidntWorkException: Something didn't work as expected. A guide to posting questions on CodeProject
Click this: Asking questions is a skill. Seriously, do it.
Dave Kreskowiak -
Nothing wrong with my question. Rather giving polite answers free from sarcasm is a skill. This is one of the reason the Internet sucks so bad.