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

[Search] Add missing property when cloning SearchOptions #27582

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Changes from 1 commit
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
Next Next commit
Use reflection to clone SearchOptions
Copy all properties using reflection to alleviate missing some properties being copied
  • Loading branch information
Mohit-Chakraborty committed Mar 16, 2022
commit ce6a37f0eb5bf5f7f4f590262f254246ef3d5cc2
31 changes: 5 additions & 26 deletions sdk/search/Azure.Search.Documents/src/Options/SearchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,32 +310,11 @@ private static void Copy(SearchOptions source, SearchOptions destination)
Debug.Assert(source != null);
Debug.Assert(destination != null);

destination.Facets = source.Facets;
destination.Filter = source.Filter;
destination.HighlightFields = source.HighlightFields;
destination.HighlightPostTag = source.HighlightPostTag;
destination.HighlightPreTag = source.HighlightPreTag;
destination.IncludeTotalCount = source.IncludeTotalCount;
destination.MinimumCoverage = source.MinimumCoverage;
destination.OrderBy = source.OrderBy;
destination.QueryAnswer = source.QueryAnswer;
destination.QueryAnswerCount = source.QueryAnswerCount;
destination.QueryCaption = source.QueryCaption;
destination.QueryCaptionHighlightEnabled = source.QueryCaptionHighlightEnabled;
destination.QueryLanguage = source.QueryLanguage;
destination.QuerySpeller = source.QuerySpeller;
destination.QueryType = source.QueryType;
destination.ScoringParameters = source.ScoringParameters;
destination.ScoringProfile = source.ScoringProfile;
destination.ScoringStatistics = source.ScoringStatistics;
destination.SearchFields = source.SearchFields;
destination.SearchMode = source.SearchMode;
destination.SearchText = source.SearchText;
destination.Select = source.Select;
destination.SemanticConfigurationName = source.SemanticConfigurationName;
destination.SemanticFields = source.SemanticFields;
destination.Size = source.Size;
destination.Skip = source.Skip;
foreach (System.Reflection.PropertyInfo sourcePropertyInfo in source.GetType().GetProperties())
{
System.Reflection.PropertyInfo destinationPropertyInfo = destination.GetType().GetProperty(sourcePropertyInfo.Name);
destinationPropertyInfo.SetValue(destination, sourcePropertyInfo.GetValue(source));
}
}

/// <summary>
Expand Down