Git Product home page Git Product logo

source_helper.dart's Introduction

Utilities to help with Dart source code generation.

Pub package Build Status package publisher

Contributing

See CONTRIBUTING.md for details.

License

Apache 2.0; see LICENSE for details.

Disclaimer

This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.

source_helper.dart's People

Contributors

dependabot[bot] avatar kevmoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

source_helper.dart's Issues

[Feature]: support escaping reserved dart keywords `escapeDartName`

Usecase:
We are maintaining a package that generates dart code from OpenAPI specs. Fields can have arbitrary names so we'd like to have a method to catch reserved dart keywords like assert, try, final, field names starting with a number or just having them kebab-case (the latter being quite common).

Implementation:
We are currently just parsing the field names to camelCase eliminating special characters and cases like snake_case and kebab-case. When the result is a reserved keyword or starting with a number we just prepend them with a $

'assert' => '$assert'
'10' => '$10'
'helloassert' => 'helloassert'

Other solutions:
As fields starting with a $ signal generated code we could also escape them in other ways. For the reserved words we could add a trailing _ although that wouldn't help with the leading numbers. I also don't really like this that much.


Would you consider such a method being in scope of this package? If yes I'll happily upstream our current implementation in the current or an altered form.

Thanks for considering this :)

Change of Copyright notice

Hello! According to the Appendix of Apache License 2.0, if you want to license your software under this License you should "attach the boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information". This condition is not met now. Please add a copyright notice in the appropriate form, including the year of the software development and your name and surname. Thank you in advance

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

[Feature]: Support camelCase in CaseHelper

First thanks for this useful package.

I'd like to kindly request a camelCase getter in CaseHelper.

Usecase:
We are maintaining a package that generates dart code from OpenAPI specs. Fields can have arbitrary names so we'd like to have a method to parse them to camelCase (as that's the dart style and also needed for some further generators).

Implementation:
The dart built_value package currently maintains a method doing this that could probably be used here:
https://github.com/google/built_value.dart/blob/7c110d259b31b9bc5a08ff4b7c92f8fd9fad850d/built_value_generator/lib/src/serializer_source_class.dart#L579-L597

As the code is also owned by google there shouldn't be any licensing problems.

If you are ok with this I'm willing to open a PR pulling the above code into this Project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.