Search code examples
c#asp.net.netcode-behind

Ambiguity between Class Variables


I'm building a system where I have some classes identical to this one:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Class to handle operations at Status table
/// </summary>
public class Status
{
    #region Vars and Class Objects
    protected Dados d;
    protected string sql;
    protected Logs log;
    protected Permissoes p;
    protected List<string> Mensagens;
    #endregion

    #region Constructor e Destructor
    public Status()
    {
        d = new Dados();
        log = new Logs();
        p = new Permissoes();
        Mensagens = new List<string>();
    }

    ~Status()
    {
        d = null;
        p = null;
        log = null;
        sql = null;
    }
    #endregion
}

(Class Logs and Class Permissoes have similar code structure).

In above code, the following errors are being shown by VS2010 IDE, for all declarations inside constructor:

Error                                                           File            Line    Col             
Ambiguity between 'Status.d' and 'Status.d'                     Status.cs       22      9
Ambiguity between 'Status.log' and 'Status.log'                 Status.cs       23      9
Ambiguity between 'Status.p' and 'Status.p'                     Status.cs       24      9
Ambiguity between 'Status.Mensagens' and 'Status.Mensagens'     Status.cs       25      9
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  21      9
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  22      9
Ambiguity between 'Status.log' and 'Status.log'                 Prioridades.cs  23      9
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  28      3
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  29      9
Ambiguity between 'Status.log' and 'Status.log'                 Prioridades.cs  30      9
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  31      9
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  45      18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  53      5
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  54      5
Ambiguity between 'Status.log' and 'Status.log'                 Prioridades.cs  58      17
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  78      18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  86      17
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  87      17
Ambiguity between 'Status.log' and 'Status.log'                 Prioridades.cs  88      17
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  106     18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  114     17
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  115     17
Ambiguity between 'Status.log' and 'Status.log'                 Prioridades.cs  116     17
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  136     18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  137     13
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  138     17
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  157     18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  158     13
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  159     26
Ambiguity between 'Status.p' and 'Status.p'                     Prioridades.cs  177     18
Ambiguity between 'Status.sql' and 'Status.sql'                 Prioridades.cs  178     4
Ambiguity between 'Status.d' and 'Status.d'                     Prioridades.cs  179     17

Strange thing is: I built another system using this very same methodology and it works like a charm. I just copy-pasted these files to another website and I'm modifying the classes to create another system.

Any ideas? It smells like bug...

EDIT:

Just found out. What happened: I copy-pasted Prioridades class, renamed it and used Refactoring on VS2010. It renamed ALL REFERENCES to "Prioridades" to "Status", including the original class... And all got messy.

Solution: be cautious when using Refactoring.

Sorry for this, guys...


Solution

  • It's interesting that it's objecting to "Status.d" in Prioridades.cs. It looks to me as if Prioridades.cs contains a class named "Status", not "Prioridades". When you copy and paste class contents (or entire files) be sure to change the class name. It's an easy thing to forget to do.