Skip to content

Commit 36b598d

Browse files
committed
Update projects to RTM. Added async/await where I could.
1 parent 0f43448 commit 36b598d

19 files changed

Lines changed: 271 additions & 258 deletions

global.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"sdk": {
3-
"version": "1.0.0-rc1-update1"
4-
},
52
"projects": [ "src", "test" ]
63
}

src/Geocoding.Core/Geocoding.Core.xproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
55
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
66
</PropertyGroup>
7-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>8f490709-2265-4aaf-bae7-a18fe054320f</ProjectGuid>
1010
<RootNamespace>Geocoding.Core</RootNamespace>
11-
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12-
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1314
</PropertyGroup>
1415
<PropertyGroup>
1516
<SchemaVersion>2.0</SchemaVersion>
1617
</PropertyGroup>
1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1819
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
1920
</PropertyGroup>
20-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
21+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
2122
</Project>
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
53

64
namespace Geocoding
75
{
86
public interface IBatchGeocoder
97
{
10-
IEnumerable<ResultItem> Geocode(IEnumerable<string> addresses);
11-
IEnumerable<ResultItem> ReverseGeocode(IEnumerable<Location> locations);
8+
Task<IEnumerable<ResultItem>> Geocode(IEnumerable<string> addresses);
9+
Task<IEnumerable<ResultItem>> ReverseGeocode(IEnumerable<Location> locations);
1210
}
1311
}

src/Geocoding.Core/IGeocoder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
33

44
namespace Geocoding
55
{
66
public interface IGeocoder
77
{
8-
IEnumerable<Address> Geocode(string address);
9-
IEnumerable<Address> Geocode(string street, string city, string state, string postalCode, string country);
8+
Task<IEnumerable<Address>> Geocode(string address);
9+
Task<IEnumerable<Address>> Geocode(string street, string city, string state, string postalCode, string country);
1010

11-
IEnumerable<Address> ReverseGeocode(Location location);
12-
IEnumerable<Address> ReverseGeocode(double latitude, double longitude);
11+
Task<IEnumerable<Address>> ReverseGeocode(Location location);
12+
Task<IEnumerable<Address>> ReverseGeocode(double latitude, double longitude);
1313
}
1414
}

src/Geocoding.Core/project.json

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
{
2-
"version": "4.0.0-beta1",
3-
"title": "Geocoding.net Core",
4-
"description": "Includes a model and interface for communicating with four popular Geocoding providers. Current implementations include: Google Maps, Yahoo! PlaceFinder, Bing Maps (aka Virtual Earth), and Mapquest. The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.",
5-
"authors": [ "chadly" ],
6-
"owners": [ "chadly" ],
7-
"tags": [ "geocoding", "geocode", "geocoder", "maps", "address", "validation", "normalization", "google-maps", "bing-maps", "yahoo-placefinder", "mapquest" ],
8-
"projectUrl": "https://github.com/chadly/Geocoding.net",
9-
"licenseUrl": "https://github.com/chadly/Geocoding.net/blob/master/LICENSE",
10-
"releaseNotes": "https://github.com/chadly/Geocoding.net/releases/latest",
2+
"version": "4.0.0-beta1",
3+
"title": "Geocoding.net Core",
4+
"description": "Includes a model and interface for communicating with four popular Geocoding providers. Current implementations include: Google Maps, Yahoo! PlaceFinder, Bing Maps (aka Virtual Earth), and Mapquest. The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.",
5+
"authors": [ "chadly" ],
6+
"packOptions": {
7+
"owners": [ "chadly" ],
8+
"tags": [ "geocoding", "geocode", "geocoder", "maps", "address", "validation", "normalization", "google-maps", "bing-maps", "yahoo-placefinder", "mapquest" ],
9+
"projectUrl": "https://github.com/chadly/Geocoding.net",
10+
"licenseUrl": "https://github.com/chadly/Geocoding.net/blob/master/LICENSE",
11+
"releaseNotes": "https://github.com/chadly/Geocoding.net/releases/latest"
12+
},
1113

12-
"frameworks": {
13-
"netcoreapp1.0": {}
14-
},
15-
"dependencies": {
16-
"Newtonsoft.Json": "9.0.1"
17-
}
14+
"frameworks": {
15+
"netstandard1.3": {}
16+
},
17+
"dependencies": {
18+
"Newtonsoft.Json": "9.0.1"
19+
}
1820
}

src/Geocoding.Google/Geocoding.Google.xproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
55
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
66
</PropertyGroup>
7-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>ca6983ad-c1b2-4524-93ff-2281c657b037</ProjectGuid>
1010
<RootNamespace>Geocoding.Google</RootNamespace>
11-
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12-
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1314
</PropertyGroup>
1415
<PropertyGroup>
1516
<SchemaVersion>2.0</SchemaVersion>
1617
</PropertyGroup>
1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1819
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
1920
</PropertyGroup>
20-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
21+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
2122
</Project>

src/Geocoding.Google/GoogleGeocoder.cs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text;
88
using System.Xml.XPath;
99
using System.Net.Http;
10+
using System.Threading.Tasks;
1011

1112
namespace Geocoding.Google
1213
{
@@ -111,46 +112,46 @@ public string ServiceUrl
111112
}
112113
}
113114

114-
public IEnumerable<GoogleAddress> Geocode(string address)
115+
public async Task<IEnumerable<GoogleAddress>> Geocode(string address)
115116
{
116117
if (string.IsNullOrEmpty(address))
117118
throw new ArgumentNullException("address");
118119

119120
var request = BuildWebRequest("address", WebUtility.UrlEncode(address));
120-
return ProcessRequest(request);
121+
return await ProcessRequest(request).ConfigureAwait(false);
121122
}
122123

123-
public IEnumerable<GoogleAddress> ReverseGeocode(Location location)
124+
public async Task<IEnumerable<GoogleAddress>> ReverseGeocode(Location location)
124125
{
125126
if (location == null)
126127
throw new ArgumentNullException("location");
127128

128-
return ReverseGeocode(location.Latitude, location.Longitude);
129+
return await ReverseGeocode(location.Latitude, location.Longitude).ConfigureAwait(false);
129130
}
130131

131-
public IEnumerable<GoogleAddress> ReverseGeocode(double latitude, double longitude)
132+
public async Task<IEnumerable<GoogleAddress>> ReverseGeocode(double latitude, double longitude)
132133
{
133134
var request = BuildWebRequest("latlng", BuildGeolocation(latitude, longitude));
134-
return ProcessRequest(request);
135+
return await ProcessRequest(request).ConfigureAwait(false);
135136
}
136137

137138
private string BuildAddress(string street, string city, string state, string postalCode, string country)
138139
{
139-
return string.Format("{0} {1}, {2} {3}, {4}", street, city, state, postalCode, country);
140+
return $"{street} {city}, {state} {postalCode}, {country}";
140141
}
141142

142143
private string BuildGeolocation(double latitude, double longitude)
143144
{
144145
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", latitude, longitude);
145146
}
146147

147-
private IEnumerable<GoogleAddress> ProcessRequest(HttpRequestMessage request)
148+
private async Task<IEnumerable<GoogleAddress>> ProcessRequest(HttpRequestMessage request)
148149
{
149150
try
150151
{
151152
using (var client = BuildClient())
152153
{
153-
return ProcessWebResponse(client.SendAsync(request).Result);
154+
return await ProcessWebResponse(await client.SendAsync(request).ConfigureAwait(false)).ConfigureAwait(false);
154155
}
155156
}
156157
catch (GoogleGeocodingException)
@@ -175,25 +176,25 @@ HttpClient BuildClient()
175176
return new HttpClient(handler);
176177
}
177178

178-
IEnumerable<Address> IGeocoder.Geocode(string address)
179+
async Task<IEnumerable<Address>> IGeocoder.Geocode(string address)
179180
{
180-
return Geocode(address).Cast<Address>();
181+
return await Geocode(address).ConfigureAwait(false);
181182
}
182183

183-
IEnumerable<Address> IGeocoder.Geocode(string street, string city, string state, string postalCode, string country)
184-
{
185-
return Geocode(BuildAddress(street, city, state, postalCode, country)).Cast<Address>();
186-
}
184+
async Task<IEnumerable<Address>> IGeocoder.Geocode(string street, string city, string state, string postalCode, string country)
185+
{
186+
return await Geocode(BuildAddress(street, city, state, postalCode, country)).ConfigureAwait(false);
187+
}
187188

188-
IEnumerable<Address> IGeocoder.ReverseGeocode(Location location)
189-
{
190-
return ReverseGeocode(location).Cast<Address>();
191-
}
189+
async Task<IEnumerable<Address>> IGeocoder.ReverseGeocode(Location location)
190+
{
191+
return await ReverseGeocode(location).ConfigureAwait(false);
192+
}
192193

193-
IEnumerable<Address> IGeocoder.ReverseGeocode(double latitude, double longitude)
194-
{
195-
return ReverseGeocode(latitude, longitude).Cast<Address>();
196-
}
194+
async Task<IEnumerable<Address>> IGeocoder.ReverseGeocode(double latitude, double longitude)
195+
{
196+
return await ReverseGeocode(latitude, longitude).ConfigureAwait(false);
197+
}
197198

198199
private HttpRequestMessage BuildWebRequest(string type, string value)
199200
{
@@ -205,9 +206,9 @@ private HttpRequestMessage BuildWebRequest(string type, string value)
205206
return new HttpRequestMessage(HttpMethod.Get, url);
206207
}
207208

208-
private IEnumerable<GoogleAddress> ProcessWebResponse(HttpResponseMessage response)
209+
private async Task<IEnumerable<GoogleAddress>> ProcessWebResponse(HttpResponseMessage response)
209210
{
210-
XPathDocument xmlDoc = LoadXmlResponse(response);
211+
XPathDocument xmlDoc = await LoadXmlResponse(response).ConfigureAwait(false);
211212
XPathNavigator nav = xmlDoc.CreateNavigator();
212213

213214
GoogleStatus status = EvaluateStatus((string)nav.Evaluate("string(/GeocodeResponse/status)"));
@@ -221,9 +222,9 @@ private IEnumerable<GoogleAddress> ProcessWebResponse(HttpResponseMessage respon
221222
return new GoogleAddress[0];
222223
}
223224

224-
private XPathDocument LoadXmlResponse(HttpResponseMessage response)
225+
private async Task<XPathDocument> LoadXmlResponse(HttpResponseMessage response)
225226
{
226-
using (Stream stream = response.Content.ReadAsStreamAsync().Result)
227+
using (Stream stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
227228
{
228229
XPathDocument doc = new XPathDocument(stream);
229230
return doc;

src/Geocoding.Google/project.json

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
2-
"version": "4.0.0-beta1",
3-
"title": "Geocoding.net Google",
4-
"description": "Includes a model and interface for communicating with four popular Geocoding providers. Current implementations include: Google Maps, Yahoo! PlaceFinder, Bing Maps (aka Virtual Earth), and Mapquest. The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.",
5-
"authors": [ "chadly" ],
6-
"owners": [ "chadly" ],
7-
"tags": [ "geocoding", "geocode", "geocoder", "maps", "address", "validation", "normalization", "google-maps", "bing-maps", "yahoo-placefinder", "mapquest" ],
8-
"projectUrl": "https://github.com/chadly/Geocoding.net",
9-
"licenseUrl": "https://github.com/chadly/Geocoding.net/blob/master/LICENSE",
10-
"releaseNotes": "https://github.com/chadly/Geocoding.net/releases/latest",
2+
"version": "4.0.0-beta1",
3+
"title": "Geocoding.net Google",
4+
"description": "Includes a model and interface for communicating with four popular Geocoding providers. Current implementations include: Google Maps, Yahoo! PlaceFinder, Bing Maps (aka Virtual Earth), and Mapquest. The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.",
5+
"authors": [ "chadly" ],
6+
"packOptions": {
7+
"owners": [ "chadly" ],
8+
"tags": [ "geocoding", "geocode", "geocoder", "maps", "address", "validation", "normalization", "google-maps", "bing-maps", "yahoo-placefinder", "mapquest" ],
9+
"projectUrl": "https://github.com/chadly/Geocoding.net",
10+
"licenseUrl": "https://github.com/chadly/Geocoding.net/blob/master/LICENSE",
11+
"releaseNotes": "https://github.com/chadly/Geocoding.net/releases/latest"
12+
},
1113

12-
"frameworks": {
13-
"netcoreapp1.0": {}
14-
},
15-
"dependencies": {
16-
"System.Xml.XPath": "4.0.1",
17-
"System.Net.Http": "4.1.0",
18-
"Geocoding.Core": "4.0.0-*"
19-
}
14+
"frameworks": {
15+
"netstandard1.3": {}
16+
},
17+
"dependencies": {
18+
"Geocoding.Core": { "target": "project" },
19+
"System.Net.Http": "4.3.0",
20+
"System.Xml.XPath": "4.3.0"
21+
}
2022
}

src/Geocoding.MapQuest/Geocoding.MapQuest.xproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
55
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
66
</PropertyGroup>
7-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
7+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>b46f0315-6ce4-414a-bdda-186090f5062c</ProjectGuid>
1010
<RootNamespace>Geocoding.MapQuest</RootNamespace>
11-
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12-
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1314
</PropertyGroup>
1415
<PropertyGroup>
1516
<SchemaVersion>2.0</SchemaVersion>
1617
</PropertyGroup>
1718
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1819
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
1920
</PropertyGroup>
20-
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
21+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
2122
</Project>

0 commit comments

Comments
 (0)