Skip to content

Commit

Permalink
update JetBrains.Annotations.dll to v 8.0.4
Browse files Browse the repository at this point in the history
add Pure and ContractAnnotation to StringExtensions
  • Loading branch information
handcraftsman committed May 15, 2013
1 parent ff4eefd commit 2150a7b
Show file tree
Hide file tree
Showing 8 changed files with 622 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -8,4 +8,5 @@ _ReSharper.*/
*.user
dist
CommonAssemblyInfo.cs
TestResult.xml
TestResult.xml
dist.bat
Binary file modified lib/JetBrains.Annotations/JetBrains.Annotations.dll
Binary file not shown.
Binary file not shown.
563 changes: 563 additions & 0 deletions lib/JetBrains.Annotations/JetBrains.Annotations.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/JetBrains.Annotations/provenance.txt
@@ -1,4 +1,4 @@
source: Resharper 4.5
source: Resharper 8

license source: http://www.jetbrains.com/resharper/buy/opensource_license.html#openSource_licenseTerms
5. LICENSE TO DISTRIBUTE JETBRAINS.ANNOTATIONS
Expand Down
62 changes: 51 additions & 11 deletions src/MvbaCore/Extensions/StringExtensions.cs
Expand Up @@ -33,7 +33,9 @@ public static void AddIfNotNullOrEmpty(this List<string> list, string item)
}
}

public static string AddSpacesToSentence(this string text)
[NotNull]
[Pure]
public static string AddSpacesToSentence([CanBeNull] this string text)
{
if (string.IsNullOrEmpty(text))
{
Expand All @@ -54,7 +56,9 @@ public static string AddSpacesToSentence(this string text)
return newText.ToString();
}

public static string GetFirstTwoWordsInSentence(this string text)
[NotNull]
[Pure]
public static string GetFirstTwoWordsInSentence([CanBeNull] this string text)
{
if (string.IsNullOrEmpty(text))
{
Expand All @@ -81,7 +85,9 @@ public static string GetFirstTwoWordsInSentence(this string text)
return newText.ToString();
}

public static string GetMD5Hash(this string input)
[NotNull]
[Pure]
public static string GetMD5Hash([NotNull] this string input)
{
var md5 = new MD5CryptoServiceProvider();
var bytes = Encoding.ASCII.GetBytes(input);
Expand All @@ -90,6 +96,9 @@ public static string GetMD5Hash(this string input)
return hash.Join("");
}

[NotNull]
[Pure]
[ContractAnnotation("separator:null => halt")]
public static IList<IList<string>> GroupBy([NotNull] this string[] lines, string separator)
{
if (separator == null)
Expand Down Expand Up @@ -125,7 +134,9 @@ public static IList<IList<string>> GroupBy([NotNull] this string[] lines, string
return groups;
}

public static byte[] HexToBytes(this string hexEncodedBytes, int start, int end)
[NotNull]
[Pure]
public static byte[] HexToBytes([NotNull] this string hexEncodedBytes, int start, int end)
{
var length = end - start;
const string tagName = "hex";
Expand All @@ -143,12 +154,16 @@ public static byte[] HexToBytes(this string hexEncodedBytes, int start, int end)
return result;
}

public static bool IsNullOrEmpty(this string input)
[Pure]
[ContractAnnotation("input:null => true")]
public static bool IsNullOrEmpty([CanBeNull] this string input)
{
return input.IsNullOrEmpty(false);
}

public static bool IsNullOrEmpty(this string input, bool trim)
[Pure]
[ContractAnnotation("input:null => true")]
public static bool IsNullOrEmpty([CanBeNull] this string input, bool trim)
{
if (String.IsNullOrEmpty(input))
{
Expand All @@ -157,6 +172,8 @@ public static bool IsNullOrEmpty(this string input, bool trim)
return trim && String.IsNullOrEmpty(input.Trim());
}

[CanBeNull, Pure]
[ContractAnnotation("input:null => null; input:notnull => notnull")]
public static string NewlinesToBr([CanBeNull] this string input)
{
if (input == null)
Expand All @@ -166,11 +183,12 @@ public static string NewlinesToBr([CanBeNull] this string input)
return input.Replace(Environment.NewLine, "<br />");
}

[CanBeNull]
[Pure]
public static string PrefixWithAOrAn([NotNull] this string str)
{
if (str.IsNullOrEmpty())
{
//throw new ArgumentNullException("str", "cannot pluralize a null or empty string");
return str;
}

Expand Down Expand Up @@ -218,6 +236,9 @@ public static string PrefixWithAOrAn([NotNull] this string str)
return "a " + str;
}

[CanBeNull]
[Pure]
[ContractAnnotation("input:null => null; input:notnull => notnull")]
public static string ReplaceIfExists([CanBeNull] this string input, string oldValue, string newValue)
{
if (input == null)
Expand All @@ -227,12 +248,17 @@ public static string ReplaceIfExists([CanBeNull] this string input, string oldVa
return !oldValue.IsNullOrEmpty() ? input.Replace(oldValue, newValue) : input;
}

public static int? SafeParseInt32(this string input)
[Pure]
[ContractAnnotation("input:null => null")]
public static int? SafeParseInt32([CanBeNull] this string input)
{
int value;
return !Int32.TryParse(input, out value) ? (int?)null : value;
}

[CanBeNull]
[Pure]
[ContractAnnotation("input:null => null; input:notnull => notnull")]
public static string TabsToNbsp([CanBeNull] this string input)
{
if (input == null)
Expand All @@ -242,6 +268,9 @@ public static string TabsToNbsp([CanBeNull] this string input)
return input.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
}

[Pure]
[CanBeNull]
[ContractAnnotation("str:null => null; str:notnull => notnull")]
public static string ToCamelCase([CanBeNull] this string str)
{
if (String.IsNullOrEmpty(str))
Expand All @@ -252,11 +281,16 @@ public static string ToCamelCase([CanBeNull] this string str)
return str;
}

public static string ToNonNull(this string input)
[NotNull]
[Pure]
public static string ToNonNull([CanBeNull] this string input)
{
return input ?? "";
}

[NotNull]
[ContractAnnotation("str:null => halt; str:notnull => notnull")]
[Pure]
public static string ToPlural([NotNull] this string str)
{
if (str.IsNullOrEmpty())
Expand Down Expand Up @@ -287,7 +321,10 @@ public static string ToPlural([NotNull] this string str)
return str + "s";
}

public static string ToTitleCase(this string value, bool lowerCaseTheRemainder = true)
[Pure]
[NotNull]
[ContractAnnotation("value:null => halt; value:notnull => notnull")]
public static string ToTitleCase([NotNull] this string value, bool lowerCaseTheRemainder = true)
{
if (value.Length == 0)
{
Expand All @@ -313,7 +350,10 @@ public static void Trace(this string message, string additionalInfo)
Diagnostics.Trace.WriteLine(DateTime.Now + " " + message + " " + additionalInfo);
}

public static string TrimIfLongerThan(this string value, int maxLength)
[NotNull]
[Pure]
[ContractAnnotation("value:null => halt;")]
public static string TrimIfLongerThan([NotNull] this string value, int maxLength)
{
return value.Length > maxLength ? value.Substring(0, maxLength) : value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MvbaCore/MvbaCore.csproj
Expand Up @@ -55,7 +55,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\FastReflection\FastReflection.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4.5.1230.4, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<Reference Include="JetBrains.Annotations, Version=8.0.4.1195, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\JetBrains.Annotations\JetBrains.Annotations.dll</HintPath>
</Reference>
Expand Down
5 changes: 4 additions & 1 deletion src/MvbaCoreTests/MvbaCoreTests.csproj
Expand Up @@ -55,7 +55,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\FluentAssert\FluentAssert.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations, Version=4.5.1230.4, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL" />
<Reference Include="JetBrains.Annotations, Version=4.5.1230.4, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\JetBrains.Annotations\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Lucene.Net, Version=2.9.2.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\Lucene\Lucene.Net.dll</HintPath>
Expand Down

0 comments on commit 2150a7b

Please sign in to comment.