Created
August 21, 2014 06:55
-
-
Save sangelov/1714cfa521696a5f1f2a to your computer and use it in GitHub Desktop.
JustCode warning for catch clauses with empty blocks
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
using System.Collections.Generic; | |
using System.ComponentModel.Composition; | |
using System.Linq; | |
using Telerik.JustCode.CommonLanguageModel; | |
namespace JustCodeExtension1 | |
{ | |
[Export(typeof(IEngineModule))] | |
[Export(typeof(ICodeMarkerGroupDefinition))] | |
public class WarningExample : CodeMarkerProviderModuleBase | |
{ | |
private const string WarningExampleID = "JustCodeExtension1WarningExampleMarker"; | |
private const string MarkerText = "Example Marker Text"; | |
private const string Description = "Example Description"; | |
private const string FixText = "Example Fix Text"; | |
protected override void AddCodeMarkers(FileModel fileModel) | |
{ | |
foreach (ICatchClause catchClause in fileModel.All<ICatchClause>().Where(c => !c.Block.ChildStatements.Any())) | |
{ | |
catchClause.AddCodeMarker(WarningExampleID, this); | |
} | |
} | |
public override IEnumerable<CodeMarkerGroup> CodeMarkerGroups | |
{ | |
get | |
{ | |
foreach (var language in new[] { LanguageNames.CSharp, LanguageNames.VisualBasic }) | |
{ | |
yield return CodeMarkerGroup.Define( | |
language, | |
WarningExampleID, | |
CodeMarkerAppearance.Warning, | |
Description, | |
true, | |
MarkerText, | |
FixText); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment