Ada Cool

Thanks

public override TargetVisibilities TargetVisibility
{
get { return TargetVisibilities.NotExternallyVisible; }
}



Re: Visual Studio Code Analysis and Code Metrics Can anybody tell me the purpose of the override propertiy

Jay Vora

The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.

When you override a property or indexer, the overridden accessors must be accessible to the overriding code. Also, the accessibility level of both the property/indexer, and that of the accessors must match the corresponding overridden property/indexer and the accessors. like.....

public class Parent
{
  public virtual int TestProperty
  {
    // Notice the accessor accessibility level.
    protected set { }

    // No access modifier is used here.
    get { return 0; }
  }
}
public class Kid : Parent
{
  public override int TestProperty
  {
    // Use the same accessibility level as in the overridden accessor.
    protected set { }

    // Cannot use access modifier here.
    get { return 0; }
  }
}





Re: Visual Studio Code Analysis and Code Metrics Can anybody tell me the purpose of the override propertiy

Jay Vora

msdn.microsoft.com/library/en-us/csref/html/vcwlkSimplePropertiesTutorial.asp frame=true

http://www.go-mono.com/docs/index.aspx link=ecmaspec%3A17.6.3






Re: Visual Studio Code Analysis and Code Metrics Can anybody tell me the purpose of the override propertiy

ada_xie

sorryŁ¬I did not say the question exactly,I want to ask you the override propertiy 's purose ,the class inherit from BaseIntrospectionRule of fxCop ,I only want to know this propertiy's function in fxCop .Thanks all of you ,my english is very bad



Re: Visual Studio Code Analysis and Code Metrics Can anybody tell me the purpose of the override propertiy

David M. Kean - MSFT

This property indicates to the FxCop the visibility of the code elements that the rule is interested in. If you overrode this property and returned NotExternallyVisible, then FxCop will only pass types, members, etc that are not externally visible outside the assembly. For example, the following shows the members that would be returned in this situation:



public class Foo
{
    public void Method1()
    {
    }
  
    protected void Method2()
    {
    }

    protected internal void Method3()
    {
    }
    internal void Method4()        // NotExternallyVisible  
    {
    }
    private void Method4()         // NotExternallyVisible
    {
    }
    internal class Bar                  // NotExternallyVisible   
    {
        public void Method1()       // NotExternallyVisible   
        {
        }
    }
}

 

Regards

David






Re: Visual Studio Code Analysis and Code Metrics Can anybody tell me the purpose of the override propertiy

Ada Cool

Thanks ,I understand .You are superman in my eyes .