The requested page is not available for the requested platform. You are viewing the content for Default platform.

Type name does not correspond to file name

CodeRush Classic shows the Type name does not correspond to file name code issue if a type name does not match the file name.

Fix

Rename the file or the type to adjust them in accordance with each other.

Purpose

Highlights the types whose name should be adjusted in accordance with the file name to improve readability and simplify working with types.

Example

//Manager.cs

using System;
using System.Collections.Generic;

namespace MySolution
{
    public class PluginManager
    {
        public List<PluginInfo> Plugins { get; private set; }
        public void AddPlugin(PluginInfo plugin)
        {
            if (Plugins == null)
                Plugins = new List<PluginInfo>();
            Plugins.Add(plugin);
        }
    }
}

Fixes:

//PluginManager.cs

using System;
using System.Collections.Generic;

namespace MySolution
{
    public class PluginManager
    {
        public List<PluginInfo> Plugins { get; private set; }
        public void AddPlugin(PluginInfo plugin)
        {
            if (Plugins == null)
                Plugins = new List<PluginInfo>();
            Plugins.Add(plugin);
        }
    }
}
//Manager.cs

using System;
using System.Collections.Generic;

namespace MySolution
{
    public class Manager
    {
        public List<PluginInfo> Plugins { get; private set; }
        public void AddPlugin(PluginInfo plugin)
        {
            if (Plugins == null)
                Plugins = new List<PluginInfo>();
            Plugins.Add(plugin);
        }
    }
}