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

Use source generator #14

Merged
merged 52 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
11f46ee
add source generator that loads all specifications
Fresa Jun 28, 2024
04c0632
fix references for the source generator test project
Fresa Jun 28, 2024
d61b70d
test(source generator): add specifications and protocol definition
Fresa Jun 28, 2024
9df762d
include transitive dependency from helper project in source generator
Fresa Jun 28, 2024
2a7235d
read the specifications and protocol definition source files and repo…
Fresa Jun 28, 2024
fa39c52
add missing dependencies to the source generator
Fresa Jun 29, 2024
d401dc6
handle json comments in the specification files
Fresa Jun 29, 2024
1e254e0
filter on both front and backslash as additional files seems to be re…
Fresa Jun 29, 2024
baef265
simplify reading text from additional texts providers
Fresa Jun 29, 2024
e8bda9a
expose add refernce to fields per message
Fresa Jun 29, 2024
7415bd5
remove unnecessary code generation directives from the source generator
Fresa Jun 29, 2024
777e0e8
test: emit files when generating
Fresa Jul 1, 2024
48ce7b2
refactor(primitives): generate using a source generator
Fresa Jul 2, 2024
3fd94f9
remove the source generator test project and generate the files in th…
Fresa Jul 2, 2024
ba1e13e
adjust the namespace of the generated primitives and remove them from…
Fresa Jul 2, 2024
87fb619
adjust using statements for primitives to the necessary once
Fresa Jul 2, 2024
49c5807
refactor(error): generate errors from source generator
Fresa Jul 2, 2024
4bab23e
add generated warning to all generated files
Fresa Jul 2, 2024
6cccffe
read different types of messages
Fresa Jul 2, 2024
1375685
include path to specification file that failed deserialization
Fresa Jul 2, 2024
b4f2238
add custom value converters for deserializing the specification files
Fresa Jul 2, 2024
bfc718c
generate create response and request message methods
Fresa Jul 3, 2024
89b5f3a
generate get response and request header version methods
Fresa Jul 3, 2024
22b1162
generate tags
Fresa Jul 5, 2024
4d71502
refactor: generate fields
Fresa Jul 5, 2024
bf09ba4
add nullable directive in generated files
Fresa Jul 5, 2024
e89a2f2
refactor: generate header messages
Fresa Jul 5, 2024
4a07ea1
fix the signature of Messages.GetResponseHeaderVersionFor
Fresa Jul 5, 2024
42f1334
fix incorrect request header message
Fresa Jul 5, 2024
e28b5b1
remove old header message code generation
Fresa Jul 5, 2024
de6893e
move primitives to separate directory
Fresa Jul 6, 2024
62f2861
add proper exception handling for the source generator
Fresa Jul 6, 2024
81300a9
fix implicit conversion problem with valuetask
Fresa Jul 6, 2024
e01283f
add regenerated create request and response message from reader methods
Fresa Jul 6, 2024
107a009
refactor: source generate messages
Fresa Jul 6, 2024
0b69ff2
fix improper syntax for get request and response header version for
Fresa Jul 6, 2024
1a5119f
add missing tags variable in create tag section method
Fresa Jul 6, 2024
127fdee
add missing using statement for linq
Fresa Jul 6, 2024
14570de
suppress known warnings for generated messages
Fresa Jul 6, 2024
fdf2c90
add pragma disable 1591 for xml comments on all generated files as we…
Fresa Jul 6, 2024
a5f16c5
remove old text template generated messages
Fresa Jul 6, 2024
b00a70a
refactor: source generate data messages
Fresa Jul 6, 2024
86ae612
remove old text template generated data messages
Fresa Jul 6, 2024
a72c09a
refactor: generate responseExtensions via source generator
Fresa Jul 6, 2024
cc1da09
remove the remaning text template generated classes
Fresa Jul 6, 2024
f3c1146
fix incorrect aggregation of message size
Fresa Jul 6, 2024
cd5334a
chore(apicompat): update to the latest version included in the .NET S…
Fresa Jul 9, 2024
8900d4a
refactor: merge the source generator helper classes into the source g…
Fresa Jul 10, 2024
f60d04b
internalize all moved source generator helper classes
Fresa Jul 10, 2024
92932b5
clean up nullable types
Fresa Jul 10, 2024
38c84a4
remove dependencies for the definition downloader and switch to httpc…
Fresa Jul 10, 2024
a8f1966
ci: build on ubuntu and add step that verifies that generated code ha…
Fresa Jul 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
os: [windows-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Setup .NET
Expand All @@ -27,6 +27,10 @@ jobs:
run: dotnet build -c Release
- name: Test
run: dotnet test -c Release --no-build --verbosity normal
- name: Ensure Generated Code Committed
shell: bash
run: |
git diff --ignore-space-at-eol --ignore-cr-at-eol --exit-code

release:
name: Create Release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ public class ErrorCode
public string Error { get; internal set; }
public int Code { get; internal set; }
public bool Retriable { get; internal set; }
public string Description { get; internal set; }
public string? Description { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,47 @@ public static bool TryGetResponseMessageDefinitionFrom(
}

public static IEnumerable<Message> AddReferencesToFields(
this IEnumerable<Message> messageDefinitions)
this IEnumerable<Message> messageDefinitions) =>
messageDefinitions
.Select(messageDefinition =>
messageDefinition.AddReferencesToFields());

public static Message AddReferencesToFields(
this Message messageDefinition)
{
foreach (var messageDefinition in messageDefinitions)
foreach (var field in messageDefinition.Fields)
{
foreach (var field in messageDefinition.Fields)
{
field.Message = messageDefinition;
AddReferenceToField(field);
}
field.Message = messageDefinition;
AddReferenceToField(field);
}

if (messageDefinition.CommonStructs != null)
if (messageDefinition.CommonStructs != null)
{
foreach (var commonStruct in messageDefinition.CommonStructs)
{
foreach (var commonStruct in messageDefinition.CommonStructs)
commonStruct.Message = messageDefinition;
foreach (var field in commonStruct.Fields)
{
commonStruct.Message = messageDefinition;
foreach (var field in commonStruct.Fields)
{
AddReferenceToField(field);
}
AddReferenceToField(field);
}
}
}

void AddReferenceToField(Field field, Field? parent = null)
{
field.Message = messageDefinition;
field.Parent = parent;
if (field.Fields == null)
{
return;
}
return messageDefinition;

foreach (var child in field.Fields)
{
AddReferenceToField(child, field);
}
void AddReferenceToField(Field field, Field? parent = null)
{
field.Message = messageDefinition;
field.Parent = parent;
if (field.Fields == null)
{
return;
}

yield return messageDefinition;
foreach (var child in field.Fields)
{
AddReferenceToField(child, field);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public class PrimitiveType
{
public string Type { get; internal set; }
public string Description { get; internal set; }
public string? Description { get; internal set; }
}
}
Loading
Loading