google / source_helper.dart Goto Github PK
View Code? Open in Web Editor NEWUtilities to help with Dart source code generation.
Home Page: https://pub.dev/packages/source_helper
License: Apache License 2.0
Utilities to help with Dart source code generation.
Home Page: https://pub.dev/packages/source_helper
License: Apache License 2.0
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.
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.
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 :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.