Skip to content

Commit 9e37845

Browse files
fix parameter mapping for provider namespace (#3070)
1 parent b8ebef7 commit 9e37845

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/AutoRest.CSharp/Mgmt/Decorator/ParameterMappingBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private static void BuildContextualParameterMappingHierarchy(RequestPath current
7777
// get the segment in pairs
7878
var segmentPairs = SplitDiffIntoPairs(diffPath).ToList();
7979
var indexOfProvidersPair = segmentPairs.FindIndex(pair => pair[0] == Segment.Providers);
80+
var resourceTypeIdVariableName = idVariableName;
8081
// from the tail, check these segments in pairs
8182
for (int i = 0; i < segmentPairs.Count; i++)
8283
{
@@ -99,7 +100,7 @@ private static void BuildContextualParameterMappingHierarchy(RequestPath current
99100
}
100101
else
101102
{
102-
parameterMappingStack.Push(new ContextualParameterMapping(keySegment.ConstantValue, valueSegment, $"{idVariableName}.ResourceType.Namespace"));
103+
parameterMappingStack.Push(new ContextualParameterMapping(keySegment.ConstantValue, valueSegment, $"{resourceTypeIdVariableName}.ResourceType.Namespace"));
103104
}
104105
// do not append a new .Parent to the id
105106
}
@@ -120,6 +121,7 @@ private static void BuildContextualParameterMappingHierarchy(RequestPath current
120121
if (keySegment.IsReference)
121122
{
122123
parameterMappingStack.Push(new ContextualParameterMapping(string.Empty, keySegment, $"{idVariableName}{invocationSuffix}.ResourceType.GetLastType()", new[] { "System.Linq" }));
124+
resourceTypeIdVariableName = $"{idVariableName}{invocationSuffix}";
123125
appendParent = true;
124126
}
125127
else if (keySegment.IsExpandable)

0 commit comments

Comments
 (0)