Skip to content

Commit 44c99bd

Browse files
committed
deprecate optional parameters in BlobExtensions
1 parent 3b0e7a8 commit 44c99bd

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

LibGit2Sharp/BlobExtensions.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,43 @@ namespace LibGit2Sharp
99
/// </summary>
1010
public static class BlobExtensions
1111
{
12+
/// <summary>
13+
/// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected
14+
/// </summary>
15+
/// <param name="blob">The blob for which the content will be returned.</param>
16+
/// <returns>Blob content as text.</returns>
17+
public static string GetContentText(this Blob blob)
18+
{
19+
Ensure.ArgumentNotNull(blob, "blob");
20+
21+
return ReadToEnd(blob.GetContentStream(), Encoding.UTF8);
22+
}
23+
1224
/// <summary>
1325
/// Gets the blob content decoded with the specified encoding,
14-
/// or according to byte order marks, with UTF8 as fallback,
15-
/// if <paramref name="encoding"/> is null.
26+
/// or according to byte order marks, or the specified encoding as a fallback
1627
/// </summary>
1728
/// <param name="blob">The blob for which the content will be returned.</param>
18-
/// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
29+
/// <param name="encoding">The encoding of the text to use, if it cannot be detected</param>
1930
/// <returns>Blob content as text.</returns>
20-
public static string GetContentText(this Blob blob, Encoding encoding = null)
31+
public static string GetContentText(this Blob blob, Encoding encoding)
2132
{
2233
Ensure.ArgumentNotNull(blob, "blob");
2334

2435
return ReadToEnd(blob.GetContentStream(), encoding);
2536
}
2637

38+
/// <summary>
39+
/// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected
40+
/// </summary>
41+
/// <param name="blob">The blob for which the content will be returned.</param>
42+
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
43+
/// <returns>Blob content as text.</returns>
44+
public static string GetContentText(this Blob blob, FilteringOptions filteringOptions)
45+
{
46+
return blob.GetContentText(filteringOptions, Encoding.UTF8);
47+
}
48+
2749
/// <summary>
2850
/// Gets the blob content as it would be checked out to the
2951
/// working directory, decoded with the specified encoding,
@@ -34,7 +56,7 @@ public static string GetContentText(this Blob blob, Encoding encoding = null)
3456
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
3557
/// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
3658
/// <returns>Blob content as text.</returns>
37-
public static string GetContentText(this Blob blob, FilteringOptions filteringOptions, Encoding encoding = null)
59+
public static string GetContentText(this Blob blob, FilteringOptions filteringOptions, Encoding encoding)
3860
{
3961
Ensure.ArgumentNotNull(blob, "blob");
4062
Ensure.ArgumentNotNull(filteringOptions, "filteringOptions");

0 commit comments

Comments
 (0)