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

generate patch files if a patch file doesn't already exist #1036

Closed
iscai-msft opened this issue Sep 17, 2021 · 4 comments
Closed

generate patch files if a patch file doesn't already exist #1036

iscai-msft opened this issue Sep 17, 2021 · 4 comments
Assignees

Comments

@iscai-msft
Copy link
Contributor

iscai-msft commented Sep 17, 2021

Since we're leaning more into encouraging people to use the patch.py to modify the generated code, we want to make it easier for people to start customizing the generated code. This will also clean up a little bit of our generated code, because we can assume that a patch.py file exists. If a patch.py file already exists, we don't do anything and keep the code the same. However, if there is no patch.py file in the generated output folder, we want to create a patch.py file (for both sync and async). This patch.py file should also have basic instructions on how to write to this patch.py file, so users have an idea when they first start out about what to do

@lmazuel
Copy link
Member

lmazuel commented Sep 17, 2021

I would suggest by default this file has no executable code, some documentation about what this file is about, and some example of commented code that you could just uncomment to start with the patch

Example

# This file is a patch file that allows to manually update the generated code behavior. Changes in this file will NOT be overwritten and will be kept from generation to generation
# yadayadayada more yadayadayada
# 
# Uncomment this code for a patch_sdk
# def patch_sdk():
#     """Use this code to change something."""
#     import this
#     this.something = True
#
# class BasicOporationCustomization:
#      def something()

@msyyc msyyc added the LLC label Oct 18, 2021
@msyyc msyyc added this to the Backlog milestone Oct 18, 2021
@msyyc
Copy link
Member

msyyc commented Oct 27, 2021

I think we may not need to add _patch.py as default behavior since customers may not use it at first. I will write a guidance about how to customize code for those who needs.

@iscai-msft
Copy link
Contributor Author

hey @msyyc our goal is to encourage SDK developers to use the _patch.py file and give them enough help to at least understand the point of this file. We also want to make our code generation cleaner in the init file, meaning we don't want to have to import the patch.py file and run patch_sdk inside a try except.

We're thinking the minimum this file should have (just to start off) is

  1. MIT license
  2. def patch_sdk(): pass
  3. A comment about what this file is used for, i.e. "This file is used for handwritten extensions to the generated code".

Then, we can add to this file with good documentation examples, i.e. "How do I handwrite overload code?", but that can be saved for later

@msyyc
Copy link
Member

msyyc commented Nov 16, 2021

Hi @iscai-msft, got it and I will do it asap.

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

No branches or pull requests

3 participants