All docs
V19.2
19.2
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

CRR0048 - The type name does not correspond to the file name

  • 2 min to read

This analyzer identifies types whose names should be adjusted in accordance with the file names to improve readability and simplify work with types.

//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);
        }
    }
}

To fix the issue, rename the file or the type to adjust them in accordance with each other:

//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);
        }
    }
}

Call the Rename Type to Match File or Rename File to Match Type refactoring to adjust the file and type in accordance with each other.