Skip to content

Commit

Permalink
Rename Blob.ContentStream() as Blob.GetContentStream()
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimeast authored and nulltoken committed Oct 27, 2013
1 parent 36945a9 commit da32029
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/BlobFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void CanReadBlobStream()
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");

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

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

Expand Down Expand Up @@ -167,7 +167,7 @@ public void CanReadBlobFilteredStreamOfUnmodifiedBinary()
{
Blob blob = repo.ObjectDatabase.CreateBlob(stream);

using (var filtered = blob.ContentStream(new FilteringOptions("foo.txt")))
using (var filtered = blob.GetContentStream(new FilteringOptions("foo.txt")))
{
Assert.True(StreamEquals(stream, filtered));
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()

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

using (Stream stream = blob.ContentStream())
using (Stream stream = blob.GetContentStream())
using (Stream file = File.OpenWrite(Path.Combine(repo.Info.WorkingDirectory, "small.fromblob.txt")))
{
CopyStream(stream, file);
Expand Down
16 changes: 14 additions & 2 deletions LibGit2Sharp/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public virtual byte[] Content
/// <summary>
/// Gets the blob content in a <see cref="Stream"/>.
/// </summary>
public virtual Stream ContentStream()
public virtual Stream GetContentStream()
{
return Proxy.git_blob_rawcontent_stream(repo.Handle, Id, Size);
}
Expand All @@ -59,10 +59,22 @@ public virtual Stream ContentStream()
/// checked out to the working directory.
/// <param name="filteringOptions">Parameter controlling content filtering behavior</param>
/// </summary>
public virtual Stream ContentStream(FilteringOptions filteringOptions)
public virtual Stream GetContentStream(FilteringOptions filteringOptions)
{
Ensure.ArgumentNotNull(filteringOptions, "filteringOptions");
return Proxy.git_blob_filtered_content_stream(repo.Handle, Id, filteringOptions.HintPath, false);
}

/// <summary>
/// Gets the blob content in a <see cref="Stream"/>.
/// </summary>
[Obsolete("This property will be removed in the next release. Please use one of the GetContentStream() overloads instead.")]
public virtual Stream ContentStream
{
get
{
return GetContentStream();
}
}
}
}
4 changes: 2 additions & 2 deletions LibGit2Sharp/BlobExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static string ContentAsText(this Blob blob, Encoding encoding = null)
{
Ensure.ArgumentNotNull(blob, "blob");

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

using(var reader = new StreamReader(blob.ContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null))
using (var reader = new StreamReader(blob.GetContentStream(filteringOptions), encoding ?? Encoding.UTF8, encoding == null))
{
return reader.ReadToEnd();
}
Expand Down

0 comments on commit da32029

Please sign in to comment.