-
Notifications
You must be signed in to change notification settings - Fork 4k
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
CDK for .NET does not use the compiler to flag construct required properties #1845
Comments
Oh, and having a nicer error message in the console would be appreciated as well😉 |
@costleya what do you think? |
@costleya what do you think of this proposition? Are all the props data structure code generated from some meta data that says if a property is required or optional? |
My take on this is that we should get rid of the props objects and replace them with keyword arguments. @eladb ? |
My take is to replace them with keyword arguments. We can definitely do this when we start doing some work on the generator. We'll try to schedule to do this work sometime in April or May. |
Related to aws/jsii#210 Adding the roslyn analyser should fix this. |
I am using the CDK version 0.24.1 with c#. If I create a stack that contains this:
It compiles perfectly. But then, when I run
cdk diff
, I get the following error:So two problems here:
FunctionProps
properties to my lambda. The required function properties arehandler
,code
andruntime
.I'd like to focus on the second point. The fact that we get a runtime error and not a compile time error is a big lost compared to TypeScript. In TypeScript, if I don't provide a required property, I see it directly in my IDE:
Given that C# is a compiled language, I would expect that all required properties be enforced at compile time.
In my opinion, the way to do this is simply to use constructor for the different
props
. For example, theFunctionProps
is currently defined like this:My suggestion would be to use a constructor with parameters instead of relying on getters/setters. Ex:
With such code, I get a nice intellisense that tells me what is required and what is optional:
And if I instantiate a
FunctionProps
and don't provide the required properties, I get a compile time error:And finally here's how it looks like when I define a lambda.
Please let me know what you think of this proposition.
The text was updated successfully, but these errors were encountered: