Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Azure Search] Fixing some long-lived bugs in the data plane SDK #4036

Merged
merged 3 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/SDKs/Search/Build-SearchPackage.ps1

This file was deleted.

3 changes: 3 additions & 0 deletions src/SDKs/Search/Build-SearchPackages.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$scriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
msbuild "$scriptDir\..\..\..\build.proj" /t:PublishNuget /p:Scope="SDKs\Search\Management" /p:NugetPackageName="Microsoft.Azure.Management.Search"
msbuild "$scriptDir\..\..\..\build.proj" /t:PublishNuget /p:Scope="SDKs\Search\DataPlane" /p:NugetPackageName="Microsoft.Azure.Search"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Azure.Search
using Microsoft.Azure.Search.Models;
using Microsoft.Spatial;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;

/// <summary>
/// Builds field definitions for an Azure Search index by reflecting over a user-defined model type.
Expand Down Expand Up @@ -53,17 +54,22 @@ public static IList<Field> BuildForType<T>(IContractResolver contractResolver)
var fields = new List<Field>();
foreach (JsonProperty prop in contract.Properties)
{
IList<Attribute> attributes = prop.AttributeProvider.GetAttributes(true);
if (attributes.Any(attr => attr is JsonIgnoreAttribute))
{
continue;
}

Copy link

@Yahnoosh Yahnoosh Feb 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a regression test for this? #Closed

Copy link
Member Author

@brjohnstmsft brjohnstmsft Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yahnoosh There are already test changes for this. Look at the test model class. #Closed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks


In reply to: 166069859 [](ancestors = 166069859)

DataType dataType = GetDataType(prop.PropertyType, prop.PropertyName);

var field = new Field(prop.PropertyName, dataType);

IList<Attribute> attributes = prop.AttributeProvider.GetAttributes(true);

foreach (Attribute attribute in attributes)
{
IsRetrievableAttribute isRetrievableAttribute;
AnalyzerAttribute analyzerAttribute;
SearchAnalyzerAttribute searchAnalyzerAttribute;
IndexAnalyzerAttribute indexAnalyzerAttribute;
IndexAnalyzerAttribute indexAnalyzerAttribute;
if (attribute is IsSearchableAttribute)
{
field.IsSearchable = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Microsoft.Azure.Search
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Search.Models;
Expand Down Expand Up @@ -36,8 +38,13 @@ public ISearchIndexClient GetClient(string indexName)
// Argument checking is done by the SearchIndexClient constructor. Note that HttpClient can't be shared in
// case it has already been used (SearchIndexClient will attempt to set the Timeout property on it).
Uri indexBaseUri = new Uri(Client.BaseUri, String.Format("indexes('{0}')", indexName));
var indexClient = new SearchIndexClient(indexBaseUri, Client.Credentials);
indexClient.HttpClient.Timeout = this.Client.HttpClient.Timeout;
var indexClient =
new SearchIndexClient(
indexBaseUri,
Client.Credentials,
Client.HttpMessageHandlers.OfType<HttpClientHandler>().SingleOrDefault());

indexClient.HttpClient.Timeout = Client.HttpClient.Timeout;
return indexClient;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description>Makes it easy to develop a .NET application that uses Azure Search.</Description>
<AssemblyTitle>Microsoft Azure Search Library</AssemblyTitle>
<AssemblyName>Microsoft.Azure.Search</AssemblyName>
<VersionPrefix>3.0.4</VersionPrefix>
<VersionPrefix>3.0.5</VersionPrefix>
<PackageTags>Microsoft Azure Search;Search</PackageTags>
<PackageReleaseNotes>This is the newest major version of the Azure Search .NET SDK, based on version 2016-09-01 of the Azure Search REST API. New in this version is support for indexing Azure Blob storage (including parsing of JSON blobs), indexing Azure Table storage, indexer field mappings, custom analyzers, and ETags. Also included is support for reflection-based field definitions via the FieldBuilder class, thanks to a contribution from Ian Griffiths (https://github.com/idg10). See this article for help on migrating to the latest version: http://aka.ms/search-sdk-upgrade.</PackageReleaseNotes>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyDescription("Makes it easy to develop a .NET application that uses Azure Search.")]

[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.4.0")]
[assembly: AssemblyFileVersion("3.0.5.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Azure.Search.Tests
using Microsoft.Azure.Search;
using Microsoft.Azure.Search.Models;
using Microsoft.Spatial;
using Newtonsoft.Json;

public class ReflectableModel
{
Expand Down Expand Up @@ -69,5 +70,15 @@ public class ReflectableModel
public int? NullableInt { get; set; }

public GeographyPoint GeographyPoint { get; set; }

[JsonIgnore]
[IsRetrievable(false)]
public RecordEnum recordEnum { get; set; }
}

public enum RecordEnum
{
Test1,
Test2
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
namespace Microsoft.Azure.Search.Tests
{
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using Microsoft.Azure.Search.Models;
using Microsoft.Azure.Search.Tests.Utilities;
using Microsoft.Rest;
using Microsoft.Rest.Azure;
using Xunit;

Expand Down Expand Up @@ -59,6 +61,29 @@ public void IndexClientHasSameTimeoutAsSearchClient()
});
}

[Fact]
public void IndexClientHasSameHandlerPipelineAsSearchClient()
{
var testClientHandler = new HttpClientHandler();

var serviceClient =
new SearchServiceClient(
"azs-test-service",
new SearchCredentials("abc"),
testClientHandler,
new FakeDelegatingHandler());

SearchIndexClient indexClient = (SearchIndexClient)serviceClient.Indexes.GetClient("test");

// Delegating handlers don't propagate to the index client because they can't be cloned, and
// therefore they can't be safely shared since the client constructors mutate each handler to
// set its inner handler.
Assert.Collection(
indexClient.HttpMessageHandlers,
h => Assert.IsType<RetryDelegatingHandler>(h),
h => Assert.Same(testClientHandler, h));
}

[Fact]
public void CanGetAnIndexClientAfterUsingServiceClient()
{
Expand Down Expand Up @@ -120,5 +145,10 @@ public void ConstructorThrowsForBadParameters()
"credentials",
() => new SearchServiceClient(uri, credentials: null, rootHandler: handler));
}

private class FakeDelegatingHandler : DelegatingHandler
{
// Do nothing.
}
}
}