Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using System.ComponentModel;

namespace Magic
{
class DerivedClass : BaseClass
{
[Obsolete("Please don't use this anymore")]
public override void Method(int argument1) => base.Method(argument1);

[EditorBrowsable(EditorBrowsableState.Never)]
public override object Property
{
get => base.Property;
set => base.Property = value;
}

[EditorBrowsable(EditorBrowsableState.Advanced)]
public override event EventHandler Event
{
add => base.Event += value;
remove => base.Event -= value;
}

[Obsolete("Please don't use this anymore")]
public override object this[int index]
{
get => base[index];
set => base[index] = value;
}
}

class BaseClass
{
public virtual void Method(int argument1)
{
}

public virtual object Property { get; set; }

public virtual event EventHandler Event
{
add { }
remove { }
}

public virtual object this[int index]
{
get => null;
set { }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ sealed class IsMeaningfulVisitor : CSharpSyntaxVisitor<bool>

public override bool VisitMethodDeclaration(MethodDeclarationSyntax node)
{
if (node.AttributeLists.Any())
{
return true;
}

var expression = node.Accept(SolitaryExpressionLocator.Instance);

if (expression == null || !expression.IsKind(SyntaxKind.InvocationExpression))
Expand All @@ -117,6 +122,11 @@ public override bool VisitMethodDeclaration(MethodDeclarationSyntax node)

public override bool VisitPropertyDeclaration(PropertyDeclarationSyntax node)
{
if (node.AttributeLists.Any())
{
return true;
}

if (node.ExpressionBody != null)
{
return !IsMatchingSelf(node.ExpressionBody.Accept(SolitaryExpressionLocator.Instance));
Expand Down Expand Up @@ -175,6 +185,11 @@ bool IsMatchingSelf(ExpressionSyntax? expression)

public override bool VisitIndexerDeclaration(IndexerDeclarationSyntax node)
{
if (node.AttributeLists.Any())
{
return true;
}

if (node.ExpressionBody != null)
{
return !IsMatchingSelf(node.ExpressionBody.Accept(SolitaryExpressionLocator.Instance));
Expand Down Expand Up @@ -234,6 +249,11 @@ bool IsMatchingSelf(ExpressionSyntax? expression)

public override bool VisitEventDeclaration(EventDeclarationSyntax node)
{
if (node.AttributeLists.Any())
{
return true;
}

foreach (var accessor in node.AccessorList.Accessors)
{
switch (accessor.Kind())
Expand Down