-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Amaury Levé
authored
Jun 12, 2017
1 parent
ab500f6
commit a6caf6f
Showing
13 changed files
with
476 additions
and
30 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...net/its/expected/Ember-MM/Ember.Plugins-{9496C697-5AFD-4813-AEDC-AF33FACEADF0}-S3908.json
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,69 @@ | ||
{ | ||
"issues": [ | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "Ember-MM\Ember.Plugins\PluginManager.cs", | ||
"region": { | ||
"startLine": 20, | ||
"startColumn": 22, | ||
"endLine": 20, | ||
"endColumn": 54 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "Ember-MM\Ember.Plugins\Scraper\MovieScraperManager.cs", | ||
"region": { | ||
"startLine": 20, | ||
"startColumn": 22, | ||
"endLine": 20, | ||
"endColumn": 61 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "Ember-MM\Ember.Plugins\Scraper\MovieScraperManager.cs", | ||
"region": { | ||
"startLine": 25, | ||
"startColumn": 22, | ||
"endLine": 25, | ||
"endColumn": 62 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "Ember-MM\Ember.Plugins\Scraper\MovieScraperManager.cs", | ||
"region": { | ||
"startLine": 30, | ||
"startColumn": 22, | ||
"endLine": 30, | ||
"endColumn": 62 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "Ember-MM\Ember.Plugins\Scraper\MovieScraperManager.cs", | ||
"region": { | ||
"startLine": 35, | ||
"startColumn": 22, | ||
"endLine": 35, | ||
"endColumn": 63 | ||
} | ||
} | ||
} | ||
] | ||
} |
56 changes: 56 additions & 0 deletions
56
...otnet/its/expected/akka.net/Akka.Remote-{EA4FF8FD-7C53-49C8-B9AA-02E458B3E6A7}-S3908.json
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,56 @@ | ||
{ | ||
"issues": [ | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "akka.net\src\core\Akka.Remote\Transport\Helios\HeliosHelpers.cs", | ||
"region": { | ||
"startLine": 166, | ||
"startColumn": 22, | ||
"endLine": 166, | ||
"endColumn": 42 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "akka.net\src\core\Akka.Remote\Transport\Helios\HeliosHelpers.cs", | ||
"region": { | ||
"startLine": 167, | ||
"startColumn": 22, | ||
"endLine": 167, | ||
"endColumn": 51 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "akka.net\src\core\Akka.Remote\Transport\Helios\HeliosHelpers.cs", | ||
"region": { | ||
"startLine": 168, | ||
"startColumn": 22, | ||
"endLine": 168, | ||
"endColumn": 50 | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "akka.net\src\core\Akka.Remote\Transport\Helios\HeliosHelpers.cs", | ||
"region": { | ||
"startLine": 169, | ||
"startColumn": 22, | ||
"endLine": 169, | ||
"endColumn": 39 | ||
} | ||
} | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
...tnet/its/expected/akka.net/Akka.TestKit-{0D3CBAD0-BBDB-43E5-AFC4-ED1D3ECDC224}-S3908.json
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,17 @@ | ||
{ | ||
"issues": [ | ||
{ | ||
"id": "S3908", | ||
"message": "Refactor this delegate to use 'System.EventHandler<TEventArgs>'.", | ||
"location": { | ||
"uri": "akka.net\src\core\Akka.TestKit\EventFilter\Internal\EventFilterBase.cs", | ||
"region": { | ||
"startLine": 33, | ||
"startColumn": 22, | ||
"endLine": 33, | ||
"endColumn": 34 | ||
} | ||
} | ||
} | ||
] | ||
} |
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,71 @@ | ||
<p>Since .Net Framework version 2.0 it is not necessary to declare a delegate that specifies a class derived from <code>System.EventArgs</code>. The | ||
<code>System.EventHandler<TEventArgs></code> delegate mechanism should be used instead as it allows any class derived from | ||
<code>EventArgs</code> to be used with that handler.</p> | ||
<p>This rule raises an issue when an old style delegate is used as an event handler.</p> | ||
<h2>Noncompliant Code Example</h2> | ||
<pre> | ||
public class MyEventArgs : EventArgs | ||
{ | ||
} | ||
|
||
public delegate void MyEventHandler(object sender, MyEventArgs e); // Noncompliant | ||
|
||
public class EventProducer | ||
{ | ||
public event MyEventHandler MyEvent; | ||
|
||
protected virtual void OnMyEvent(MyEventArgs e) | ||
{ | ||
if (MyEvent != null) | ||
{ | ||
MyEvent(e); | ||
} | ||
} | ||
} | ||
|
||
public class EventConsumer | ||
{ | ||
public EventConsumer(EventProducer producer) | ||
{ | ||
producer.MyEvent += HandleEvent; | ||
} | ||
|
||
private void HandleEvent(object sender, MyEventArgs e) | ||
{ | ||
// Do something... | ||
} | ||
} | ||
</pre> | ||
<h2>Compliant Solution</h2> | ||
<pre> | ||
public class MyEventArgs : EventArgs | ||
{ | ||
} | ||
|
||
public class EventProducer | ||
{ | ||
public event EventHandler<MyEventArgs> MyEvent; | ||
|
||
protected virtual void OnMyEvent(MyEventArgs e) | ||
{ | ||
if (MyEvent != null) | ||
{ | ||
MyEvent(e); | ||
} | ||
} | ||
} | ||
|
||
public class EventConsumer | ||
{ | ||
public EventConsumer(EventProducer producer) | ||
{ | ||
producer.MyEvent += HandleEvent; | ||
} | ||
|
||
private void HandleEvent(object sender, MyEventArgs e) | ||
{ | ||
// Do something... | ||
} | ||
} | ||
</pre> | ||
|
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,13 @@ | ||
{ | ||
"title": "Generic event handlers should be used", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "15min" | ||
}, | ||
"tags": [ | ||
|
||
], | ||
"defaultSeverity": "Major" | ||
} |
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
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
Oops, something went wrong.