-
Notifications
You must be signed in to change notification settings - Fork 2
[OnHold] [16225092] getCsharpComments Util method #14
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
base: master
Are you sure you want to change the base?
Conversation
aeshanw-aelf
commented
Oct 5, 2023
- This is a C# rewrite of https://github.com/AElfProject/contract-plugin/blob/master/src/contract_csharp_generator_helpers.h#L37
- Also includes a basic unit-test
|
|
||
| // Act: Call the GetClassName method | ||
| var comments = ProtoUtils.GetCsharpComments(file, true); | ||
| const string expectedComments = @"// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expected output doesn't seem right. We need to fix either the code or the test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think ill fix the code (y). the spaces are too big.
|
I've removed the redundant line-breaks + extra-spaces. so the output comments look more compact. lemme know ur thoughts. thx! |
src/ContractGenerator/ProtoUtils.cs
Outdated
|
|
||
| /// <summary> | ||
| /// This Util GetCsharpComments gets/generates C# comments based on the proto. Copied from the C++ original | ||
| /// https://github.com/protocolbuffers/protobuf/blob/e57166b65a6d1d55fc7b18beaae000565f617f22/src/google/protobuf/compiler/csharp/csharp_helpers.cc#L255C35-L255C50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL is wrong.
src/ContractGenerator/ProtoUtils.cs
Outdated
|
|
||
| /// <summary> | ||
| /// This Util gets the GetPrefixedComments based on the proto. Copied from the C++ original | ||
| /// https://github.com/protocolbuffers/protobuf/blob/e57166b65a6d1d55fc7b18beaae000565f617f22/src/google/protobuf/compiler/csharp/csharp_helpers.cc#L255C35-L255C50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL is wrong.
| // Actions (methods that modify contract state) | ||
| // Stores the value in contract state | ||
| // Views (methods that don't modify contract state) | ||
| // Get the value stored from contract state | ||
| // An event that will be emitted from contract method call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not file level comments. Is this output correct? It makes no sense to print out the comments for methods and messages like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm these comments are present in the file tho i suppose it would be best to just print the top-level file-proto comments? i.e just // These are test header comments! based on the example below. wdyt?
syntax = "proto3";
// These are test header comments!
import "aelf/options.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
// The namespace of this class
option csharp_namespace = "AElf.Contracts.HelloWorld";
service HelloWorld {
// The name of the state class the smart contract is going to use to access blockchain state
option (aelf.csharp_state) = "AElf.Contracts.HelloWorld.HelloWorldState";
// Actions (methods that modify contract state)
// Stores the value in contract state
rpc Update (google.protobuf.StringValue) returns (google.protobuf.Empty) {
}
// Views (methods that don't modify contract state)
// Get the value stored from contract state
rpc Read (google.protobuf.Empty) returns (google.protobuf.StringValue) {
option (aelf.is_view) = true;
}
}
// An event that will be emitted from contract method call
message UpdatedMessage {
option (aelf.is_event) = true;
string value = 1;
}