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

Move some more helpers from shared code to generated helpers #4675

Draft
wants to merge 10 commits into
base: feature/v3
Choose a base branch
from

Conversation

ArcturusZhang
Copy link
Member

Description

Add your description here!

Checklist

To ensure a quick review and merge, please ensure:

  • The PR has a understandable title and description explaining the why and what.
  • The PR is opened in draft if not ready for review yet.
    • If opened in draft, please allocate sufficient time (24 hours) after moving out of draft for review
  • The branch is recent enough to not have merge conflicts upon creation.

Ready to Land?

  • Build is completely green
    • Submissions with test failures require tracking issue and approval of a CODEOWNER
  • At least one +1 review by a CODEOWNER
  • All -1 reviews are confirmed resolved by the reviewer
    • Override/Marking reviews stale must be discussed with CODEOWNERS first

@@ -28,9 +27,10 @@ namespace AutoRest.CSharp.Generation.Writers
{
internal static class RequestWriterHelpers
{
public static void WriteRequestAndUriCreation(CodeWriter writer, RestClientMethod clientMethod, string methodAccessibility, ClientFields fields, string? responseClassifierType, bool writeSDKUserAgent, IReadOnlyList<Parameter>? clientParameters = null)
// This only serves the MPG now
public static void WriteRequestAndUriCreation(CodeWriter writer, RestClientMethod clientMethod, ClientFields fields, string? responseClassifierType, bool writeSDKUserAgent, IReadOnlyList<Parameter>? clientParameters = null)
Copy link
Member Author

Choose a reason for hiding this comment

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

removed this methodAccessibility parameter because in everywhere it is getting invoked, we are always passing in internal.

@@ -72,7 +72,7 @@ public static IEnumerable<MethodBodyStatement> BuildMultipartSerializationMethod
/*return BinaryData.FromStream(stream);*/
Return(BinaryDataExpression.FromStream(stream, false)),
/*return new BinaryData(stream.GetBuffer().AsMemory(0, (int)stream.Position));*/
Return(New.Instance(typeof(BinaryData), new[]{ new InvokeInstanceMethodExpression((new StreamExpression(stream)).GetBuffer, "AsMemory", new[] { Literal(0), new CastExpression(stream.Property("Position"), typeof(int)) }, null, false) }))
Return(New.Instance(typeof(BinaryData), new[]{ new InvokeInstanceMethodExpression(new StreamExpression(stream).GetBuffer(), "AsMemory", new[] { Literal(0), new CastExpression(stream.Property("Position"), typeof(int)) }, null, false) }))
Copy link
Member Author

Choose a reason for hiding this comment

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

The GetBuffer on Stream class is a method, therefore our expression should express it as a method even if it takes no arguments.

@@ -457,7 +457,7 @@ private static ValueExpression DeserializeValue(XmlValueSerialization serializat

if (frameworkType == typeof(object))
{
return element.GetObjectValue(serialization.Format.ToFormatSpecifier());
return element.Value;
Copy link
Member Author

Choose a reason for hiding this comment

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

in the extension, the XElement.GetObjectValue method is just calling element.Value, therefore we just remove it to call this directly

@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch 3 times, most recently from cfde916 to cfa16cb Compare April 30, 2024 06:42
@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch from cfa16cb to b0260d3 Compare April 30, 2024 08:07
@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch 2 times, most recently from 5d9e020 to 46c7a81 Compare April 30, 2024 12:30
@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch from 46c7a81 to 65402be Compare May 6, 2024 08:15
@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch from ca93a0d to a827900 Compare May 7, 2024 02:04
@ArcturusZhang ArcturusZhang force-pushed the add-other-helpers-for-azure-libraries branch from a827900 to 4871229 Compare May 7, 2024 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant