-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overrides with additional attributes aren't entirely pointless. (#148)
* Add test for subclass adding attributes * Add tests for property and event * add Indexer test * Overrides that declare attributes should not be considered pointless.
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
WTG.Analyzers.Test/TestData/PointlessOverrideAnalyzer/Attributes/Source.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters