@@ -9,21 +9,43 @@ namespace LibGit2Sharp
9
9
/// </summary>
10
10
public static class BlobExtensions
11
11
{
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
+
12
24
/// <summary>
13
25
/// 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
16
27
/// </summary>
17
28
/// <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>
19
30
/// <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 )
21
32
{
22
33
Ensure . ArgumentNotNull ( blob , "blob" ) ;
23
34
24
35
return ReadToEnd ( blob . GetContentStream ( ) , encoding ) ;
25
36
}
26
37
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
+
27
49
/// <summary>
28
50
/// Gets the blob content as it would be checked out to the
29
51
/// working directory, decoded with the specified encoding,
@@ -34,7 +56,7 @@ public static string GetContentText(this Blob blob, Encoding encoding = null)
34
56
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
35
57
/// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
36
58
/// <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 )
38
60
{
39
61
Ensure . ArgumentNotNull ( blob , "blob" ) ;
40
62
Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
0 commit comments