Skip to content

Commit

Permalink
Fix crash when file does not contain header text
Browse files Browse the repository at this point in the history
  • Loading branch information
citizenmatt committed Dec 20, 2016
1 parent 72e3251 commit 9c98a78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion install/StyleCop.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<metadata>
<id>StyleCop.StyleCop</id>
<title>StyleCop by JetBrains</title>
<version>2016.3.0</version>
<version>2016.3.1</version>
<authors>Matt Ellis, Andy Reeves</authors>
<owners>JetBrains, Matt Ellis</owners>
<summary>StyleCop analyzes C# source code to enforce a set of style and consistency rules. Maintained by JetBrains</summary>
<description>StyleCop analyzes C# source code to enforce a set of style and consistency rules. This plugin is compatible with StyleCop 4.7.54, and maintained by JetBrains.</description>
<releaseNotes>
&#8226; Fix crash if the file doesn't have a header (StyleCop/StyleCop#78)
&#8226; Updated to ReSharper 2016.3

From 2016.2.1:
Expand Down
8 changes: 7 additions & 1 deletion src/StyleCop.ReSharper/Core/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,13 @@ public static ITreeNode GetElementAtCaret(ISolution solution, ITextControl textC
/// </returns>
public static string GetFileHeader(ICSharpFile file)
{
return GetFileHeaderTreeRange(file).GetDocumentRange().GetText();
var documentRange = GetFileHeaderTreeRange(file).GetDocumentRange();
if (!documentRange.IsValid())
{
return string.Empty;
}

return documentRange.GetText();
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/StyleCop.ReSharper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
using System.Runtime.InteropServices;
using JetBrains.ReSharper.Feature.Services.Daemon;

[assembly: AssemblyTitle("StyleCop R# 8.0.0 Plugin")]
[assembly: AssemblyDescription("R# plugin for StyleCop")]
[assembly: AssemblyTitle("StyleCop for ReSharper")]
[assembly: AssemblyDescription("StyleCop for ReSharper")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct(StyleCop.Constants.ProductName)]
Expand Down

0 comments on commit 9c98a78

Please sign in to comment.