Skip to content

Instantly share code, notes, and snippets.

@sangelov
Created August 21, 2014 06:55
Show Gist options
  • Save sangelov/1714cfa521696a5f1f2a to your computer and use it in GitHub Desktop.
Save sangelov/1714cfa521696a5f1f2a to your computer and use it in GitHub Desktop.
JustCode warning for catch clauses with empty blocks
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