I am applying symbology from a layer using the code snippet at https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring#apply-symbology-to-a-layer-from-a-layer-file. When I use this method to update the symbology for a point layer, the symbols are updated but the symbol classes are maintained; the equivalent of 'maintain ranges' in the ApplySymbologyFromLayer tool. I would like for the symbol classes to be updated to only show the classes that are existent in the current data. Not all the classes from the symbology layer file. The equivalent of this in the ApplySymbologyFromLayer tool would be 'update ranges' and when I run this tool in Pro using 'update ranges', it does what I want.
So the question is how can I use the code below to update symbology ranges and not just maintain them?
var lyrDocFromLyrxFile = new LayerDocument(layerFile);
var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument();
var rendererFromLayerFile = ((CIMFeatureLayer)cimLyrDoc.LayerDefinitions[0]).Renderer as CIMUniqueValueRenderer;
featureLayer?.SetRenderer(rendererFromLayerFile);
@CharlesMacleod @Wolf @UmaHarano