user5640007
user5640007

Reputation:

How can I determine the type of C# file in Visual Studio?

When you try to create a new C# file in Visual Studio, one has plenty of options. And most of the different file types, like Windows Form, Custom Control, C# Class file, Installer Class, etc. have have an extension .cs. I know that in the base they are all just C# files, and Visual Studio just includes some code snippets for our chosen file type. But, is it possible to somehow check what kind of file type has been used in Visual Studio, when created that particular source file?

For example, I have a file in a solution called FileDialogPane.cs, and inside I have something like this:

using System;
using System.ComponentModel;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;

namespace Project.File
{
    internal class FileDialogPage : DialogPage
    {
        public FileDialogPage()
        {
            InitializeSettings();
        }

        // rest removed for brevity
    }
} 

And it doesn't have a default .cs style logo in Visual Studio, and I really want to figure out what kind of file was used when creating it.

Upvotes: 0

Views: 714

Answers (2)

Steve Cooper
Steve Cooper

Reputation: 21490

No, I'm afraid not -- not generally. Once created, that's it.

Upvotes: 0

Gregor Menih
Gregor Menih

Reputation: 5126

Usually, checking inheritance works. You can see this file inherits the class DialogPage, which makes this a DialogPage file.

Upvotes: 1

Related Questions