@@ -9,21 +9,44 @@ 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 from the byte order mark
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 ( ) , null ) ;
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" ) ;
34
+ Ensure . ArgumentNotNull ( encoding , "encoding" ) ;
23
35
24
36
return ReadToEnd ( blob . GetContentStream ( ) , encoding ) ;
25
37
}
26
38
39
+ /// <summary>
40
+ /// Gets the blob content, decoded with UTF8 encoding if the encoding cannot be detected
41
+ /// </summary>
42
+ /// <param name="blob">The blob for which the content will be returned.</param>
43
+ /// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
44
+ /// <returns>Blob content as text.</returns>
45
+ public static string GetContentText ( this Blob blob , FilteringOptions filteringOptions )
46
+ {
47
+ return blob . GetContentText ( filteringOptions , null ) ;
48
+ }
49
+
27
50
/// <summary>
28
51
/// Gets the blob content as it would be checked out to the
29
52
/// working directory, decoded with the specified encoding,
@@ -34,7 +57,7 @@ public static string GetContentText(this Blob blob, Encoding encoding = null)
34
57
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
35
58
/// <param name="encoding">The encoding of the text. (default: detected or UTF8)</param>
36
59
/// <returns>Blob content as text.</returns>
37
- public static string GetContentText ( this Blob blob , FilteringOptions filteringOptions , Encoding encoding = null )
60
+ public static string GetContentText ( this Blob blob , FilteringOptions filteringOptions , Encoding encoding )
38
61
{
39
62
Ensure . ArgumentNotNull ( blob , "blob" ) ;
40
63
Ensure . ArgumentNotNull ( filteringOptions , "filteringOptions" ) ;
0 commit comments