diff --git a/Octokit.Reactive/Clients/IObservableSearchClient.cs b/Octokit.Reactive/Clients/IObservableSearchClient.cs
index 37a75825..5e8ef92e 100644
--- a/Octokit.Reactive/Clients/IObservableSearchClient.cs
+++ b/Octokit.Reactive/Clients/IObservableSearchClient.cs
@@ -37,6 +37,6 @@ namespace Octokit.Reactive
///
///
/// List of files
- IObservable SearchCode(SearchCodeRequest search);
+ IObservable SearchCode(SearchCodeRequest search);
}
}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableSearchClient.cs b/Octokit.Reactive/Clients/ObservableSearchClient.cs
index 220cc48e..029afaa7 100644
--- a/Octokit.Reactive/Clients/ObservableSearchClient.cs
+++ b/Octokit.Reactive/Clients/ObservableSearchClient.cs
@@ -63,10 +63,10 @@ namespace Octokit.Reactive
///
///
/// List of files
- public IObservable SearchCode(SearchCodeRequest search)
+ public IObservable SearchCode(SearchCodeRequest search)
{
Ensure.ArgumentNotNull(search, "search");
- return _connection.GetAndFlattenAllPages(ApiUrls.SearchCode(), search.Parameters);
+ return _client.Search.SearchCode(search).ToObservable();
}
}
}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
index da5204e7..55559cb0 100644
--- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs
@@ -32,4 +32,14 @@ public class SearchClientTests
Assert.NotEmpty(repos.Items);
}
+
+ [Fact]
+ public async Task SearchForFunctionInCode()
+ {
+ var request = new SearchCodeRequest("addClass");
+ request.Repo = "jquery/jquery";
+ var repos = await _gitHubClient.Search.SearchCode(request);
+
+ Assert.NotEmpty(repos.Items);
+ }
}
diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs
index 2aac476c..0ffa0e85 100644
--- a/Octokit.Tests/Clients/SearchClientTests.cs
+++ b/Octokit.Tests/Clients/SearchClientTests.cs
@@ -1029,7 +1029,7 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For();
var client = new SearchClient(connection);
client.SearchCode(new SearchCodeRequest("something"));
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Any>());
}
@@ -1050,7 +1050,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something"));
}
@@ -1065,7 +1065,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["sort"] == "indexed"));
}
@@ -1081,7 +1081,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d =>
d["sort"] == "indexed" &&
@@ -1097,7 +1097,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["order"] == "desc"));
}
@@ -1113,7 +1113,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+in:file"));
}
@@ -1128,7 +1128,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+in:file,path"));
}
@@ -1143,7 +1143,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+language:C#"));
}
@@ -1158,7 +1158,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+fork:true"));
}
@@ -1173,7 +1173,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+size:>10"));
}
@@ -1188,7 +1188,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+size:>=10"));
}
@@ -1203,7 +1203,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+size:<10"));
}
@@ -1218,7 +1218,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+size:<=10"));
}
@@ -1233,7 +1233,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+size:10..100"));
}
@@ -1248,7 +1248,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+path:app/public"));
}
@@ -1263,7 +1263,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+extension:cs"));
}
@@ -1278,7 +1278,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+user:alfhenrik"));
}
@@ -1293,7 +1293,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d => d["q"] == "something+repo:octokit.net"));
}
@@ -1310,7 +1310,7 @@ namespace Octokit.Tests.Clients
client.SearchCode(request);
- connection.Received().GetAll(
+ connection.Received().Get(
Arg.Is(u => u.ToString() == "search/code"),
Arg.Is>(d =>
d["q"] == "something+path:tools/FAKE.core+extension:fs+repo:octokit.net"));
diff --git a/Octokit/Clients/ISearchClient.cs b/Octokit/Clients/ISearchClient.cs
index 8119aa37..d6729ad5 100644
--- a/Octokit/Clients/ISearchClient.cs
+++ b/Octokit/Clients/ISearchClient.cs
@@ -39,6 +39,6 @@ namespace Octokit
///
///
/// List of files
- Task> SearchCode(SearchCodeRequest search);
+ Task SearchCode(SearchCodeRequest search);
}
}
\ No newline at end of file
diff --git a/Octokit/Clients/SearchClient.cs b/Octokit/Clients/SearchClient.cs
index 9cfb6041..269fc44c 100644
--- a/Octokit/Clients/SearchClient.cs
+++ b/Octokit/Clients/SearchClient.cs
@@ -61,10 +61,10 @@ namespace Octokit
///
///
/// List of files
- public Task> SearchCode(SearchCodeRequest search)
+ public Task SearchCode(SearchCodeRequest search)
{
Ensure.ArgumentNotNull(search, "search");
- return ApiConnection.GetAll(ApiUrls.SearchCode(), search.Parameters);
+ return ApiConnection.Get(ApiUrls.SearchCode(), search.Parameters);
}
}
}
\ No newline at end of file
diff --git a/Octokit/Models/Response/SearchCodeResult.cs b/Octokit/Models/Response/SearchCodeResult.cs
new file mode 100644
index 00000000..3ca65183
--- /dev/null
+++ b/Octokit/Models/Response/SearchCodeResult.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace Octokit
+{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ public class SearchCodeResult
+ {
+ public int TotalCount { get; set; }
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public IReadOnlyList Items { get; set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return String.Format(CultureInfo.InvariantCulture, "TotalCount: {0}", TotalCount);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index bb7803d3..3283b1a4 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -308,6 +308,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 19b956e7..71f33175 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -319,6 +319,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 24c46fcf..c92023a3 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -314,6 +314,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index f7b3c62e..8d9e466f 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -306,6 +306,7 @@
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index a284967b..1c058fdd 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -140,6 +140,7 @@
+