8000 Rename Blob.ContentStream() as Blob.GetContentStream() · philhack/libgit2sharp@da32029 · GitHub
[go: up one dir, main page]

Skip to content

Commit da32029

Browse files
Aimeastnulltoken
authored andcommitted
Rename Blob.ContentStream() as Blob.GetContentStream()
1 parent 36945a9 commit da32029

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void CanReadBlobStream()
122122
{
123123
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
124124

125-
using (var tr = new StreamReader(blob.ContentStream(), Encoding.UTF8))
125+
using (var tr = new StreamReader(blob.GetContentStream(), Encoding.UTF8))
126126
{
127127
string content = tr.ReadToEnd();
128128
Assert.Equal("hey there\n", content);
@@ -137,7 +137,7 @@ public void CanReadBlobFilteredStream()
137137
{
138138
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
139139

140-
using (var tr = new StreamReader(blob.ContentStream(new FilteringOptions("foo.txt")), Encoding.UTF8))
140+
using (var tr = new StreamReader(blob.GetContentStream(new FilteringOptions("foo.txt")), Encoding.UTF8))
141141
{
142142
string content = tr.ReadToEnd();
143143

@@ -167,7 +167,7 @@ public void CanReadBlobFilteredStreamOfUnmodifiedBinary()
167167
{
168168
Blob blob = repo.ObjectDatabase.CreateBlob(stream);
169169

170-
using (var filtered = blob.ContentStream(new FilteringOptions("foo.txt")))
170+
using (var filtered = blob.GetContentStream(new FilteringOptions("foo.txt")))
171171
{
172172
Assert.True(StreamEquals(stream, filtered));
173173
}
@@ -198,7 +198,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
198198

199199
var blob = repo.Lookup<Blob>(entry.Id.Sha);
200200

201-
using (Stream stream = blob.ContentStream())
201+
using (Stream stream = blob.GetContentStream())
202202
using (Stream file = File.OpenWrite(Path.Combine(repo.Info.WorkingDirectory, "small.fromblob.txt")))
203203
{
204204
CopyStream(stream, file);

LibGit2Sharp/Blob.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public virtual byte[] Content
4949
/// <summary>
5050
/// Gets the blob content in a <see cref="Stream"/>.
5151
/// </summary>
52-
public virtual Stream ContentStream()
52+
public virtual Stream GetContentStream()
5353
{
5454
return Proxy.git_blob_rawcontent_stream(repo.Handle, Id, Size);
5555
}
@@ -59,10 +59,22 @@ public virtual Stream ContentStream()
5959
/// checked out to the working directory.
6060
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
6161
/// </summary>
62-
public virtual Stream ContentStream(FilteringOptions filteringOptions)
62+
public virtual Stream GetContentStream(FilteringOptions filteringOptions)
6363
{
6464
Ensure.ArgumentNotNull(filteringOptions, "filteringOptions");
6565
return Proxy.git_blob_filtered_content_stream(repo.Handle, Id, filteringOptions.HintPath, false);
6666
}
67+
68+
/// <summary>
69+
/// Gets the blob content in a <see cref="Stream"/>.
70+
/// </summary>
71+
[Obsolete("This property will be removed in the next release. Please use one of the GetContentStream() overloads instead.")]
72+
public virtual Stream ContentStream
73+
{
74+
get
75+
{
76+
return GetContentStream();
77+
}
78+
}
6779
}
6880
}

LibGit2Sharp/BlobExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static string ContentAsText(this Blob blob, Encoding encoding = null)
2222
{
2323
Ensure.ArgumentNotNull(blob, "blob");
2424

25-
using (var reader = new StreamReader(blob.ContentStream(), encoding ?? Encoding.UTF8, encoding == null))
25+
using (var reader = new StreamReader(blob.GetContentStream(), encoding ?? Encoding.UTF8, encoding == null))
2626
{
2727
return reader.ReadToEnd();
2828
}
@@ -43,7 +43,7 @@ public static string ContentAsText(this Blob blob, FilteringOptions filteringOpt
4343
Ensure.ArgumentNotNull(blob, "blob");
4444
Ensure.ArgumentNotNull(filteringOptions, "filteringOptions");
4545

46-
using(var reader = new StreamReader(blob.ContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null))
46+
using (var reader = new StreamReader(blob.GetContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null))
4747
{
4848
return reader.ReadToEnd();
4949
}

0 commit comments

Comments
 (0)
0