-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix(.NET): Improve Collection of Errors string #1158
Open
texastony
wants to merge
4
commits into
main
Choose a base branch
from
tony/fix-collectionOfErrors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7969f17
fix(.NET): Improve Collection of Errors string
texastony 56a3428
Merge branch 'main' into tony/fix-collectionOfErrors
rishav-karanjit fae036c
Merge branch 'main' into tony/fix-collectionOfErrors
texastony 049f345
Merge branch 'main' into tony/fix-collectionOfErrors
josecorella File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...erialProviders/codegen-patches/AwsCryptographicMaterialProviders/dotnet/dafny-4.9.0.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/CollectionOfErrors.cs a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/CollectionOfErrors.cs | ||
index 8f7200422..39f044046 100644 | ||
--- b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/CollectionOfErrors.cs | ||
+++ a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/CollectionOfErrors.cs | ||
@@ -8,9 +8,18 @@ namespace AWS.Cryptography.MaterialProviders | ||
public class CollectionOfErrors : Exception | ||
{ | ||
public readonly System.Collections.Generic.List<Exception> list; | ||
- public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message) { this.list = list; } | ||
+ public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message + $"\n List: \n{ListAsString(list)}") { this.list = list; } | ||
public CollectionOfErrors(string message) : base(message) { this.list = new System.Collections.Generic.List<Exception>(); } | ||
public CollectionOfErrors() : base("CollectionOfErrors") { this.list = new System.Collections.Generic.List<Exception>(); } | ||
+ | ||
+ private static string ListAsString(List<Exception> list) | ||
+ { | ||
+ if (list.Count < 1) return ""; | ||
+ string[] msgArr = new string[list.Count]; | ||
+ for (int i = 0; i < list.Count; i++) | ||
+ msgArr[i] = $"{list[i].GetType().Name} :: {list[i].Message}"; | ||
+ return String.Join("\n\t", msgArr); | ||
+ } | ||
} | ||
|
||
} | ||
diff --git b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/TypeConversion.cs a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/TypeConversion.cs | ||
index d5ab49915..446365249 100644 | ||
--- b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/TypeConversion.cs | ||
+++ a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/TypeConversion.cs | ||
@@ -3946,7 +3946,9 @@ namespace AWS.Cryptography.MaterialProviders | ||
dafnyVal._ComAmazonawsDynamodb | ||
); | ||
case software.amazon.cryptography.materialproviders.internaldafny.types.Error_ComAmazonawsKms dafnyVal: | ||
- return Com.Amazonaws.KMS.TypeConversion.FromDafny_CommonError( | ||
+ // BEGIN MANUAL EDIT | ||
+ return Com.Amazonaws.Kms.TypeConversion.FromDafny_CommonError( | ||
+ // END MANUAL EDIT | ||
dafnyVal._ComAmazonawsKms | ||
); | ||
case software.amazon.cryptography.materialproviders.internaldafny.types.Error_AwsCryptographicMaterialProvidersException dafnyVal: |
50 changes: 50 additions & 0 deletions
50
...graphicMaterialProviders/codegen-patches/AwsCryptographyKeyStore/dotnet/dafny-4.9.0.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
diff --git b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/CollectionOfErrors.cs a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/CollectionOfErrors.cs | ||
index e752a715a..e203599b2 100644 | ||
--- b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/CollectionOfErrors.cs | ||
+++ a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/CollectionOfErrors.cs | ||
@@ -8,9 +8,17 @@ namespace AWS.Cryptography.KeyStore | ||
public class CollectionOfErrors : Exception | ||
{ | ||
public readonly System.Collections.Generic.List<Exception> list; | ||
- public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message) { this.list = list; } | ||
+ public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message + $"\n List: \n{ListAsString(list)}") { this.list = list; } | ||
public CollectionOfErrors(string message) : base(message) { this.list = new System.Collections.Generic.List<Exception>(); } | ||
public CollectionOfErrors() : base("CollectionOfErrors") { this.list = new System.Collections.Generic.List<Exception>(); } | ||
- } | ||
|
||
+ private static string ListAsString(List<Exception> list) | ||
+ { | ||
+ if (list.Count < 1) return ""; | ||
+ string[] msgArr = new string[list.Count]; | ||
+ for (int i = 0; i < list.Count; i++) | ||
+ msgArr[i] = $"{list[i].GetType().Name} :: {list[i].Message}"; | ||
+ return String.Join("\n\t", msgArr); | ||
+ } | ||
+ } | ||
} | ||
diff --git b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/TypeConversion.cs a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/TypeConversion.cs | ||
index b7ee7eb89..9c9b351d5 100644 | ||
--- b/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/TypeConversion.cs | ||
+++ a/AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/TypeConversion.cs | ||
@@ -736,7 +736,9 @@ namespace AWS.Cryptography.KeyStore | ||
dafnyVal._ComAmazonawsDynamodb | ||
); | ||
case software.amazon.cryptography.keystore.internaldafny.types.Error_ComAmazonawsKms dafnyVal: | ||
- return Com.Amazonaws.KMS.TypeConversion.FromDafny_CommonError( | ||
+ // BEGIN MANUAL EDIT | ||
+ return Com.Amazonaws.Kms.TypeConversion.FromDafny_CommonError( | ||
+ // END MANUAL EDIT | ||
dafnyVal._ComAmazonawsKms | ||
); | ||
case software.amazon.cryptography.keystore.internaldafny.types.Error_KeyStoreException dafnyVal: | ||
@@ -761,7 +763,9 @@ namespace AWS.Cryptography.KeyStore | ||
{ | ||
case "Com.Amazonaws.KMS": | ||
return software.amazon.cryptography.keystore.internaldafny.types.Error.create_ComAmazonawsKms( | ||
- Com.Amazonaws.KMS.TypeConversion.ToDafny_CommonError(value) | ||
+ // BEGIN MANUAL EDIT | ||
+ Com.Amazonaws.Kms.TypeConversion.ToDafny_CommonError(value) | ||
+ // END MANUAL EDIT | ||
); | ||
case "Com.Amazonaws.Dynamodb": | ||
return software.amazon.cryptography.keystore.internaldafny.types.Error.create_ComAmazonawsDynamodb( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
AwsCryptographyPrimitives/codegen-patches/dotnet/dafny-4.9.0.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git b/AwsCryptographyPrimitives/runtimes/net/Generated/CollectionOfErrors.cs a/AwsCryptographyPrimitives/runtimes/net/Generated/CollectionOfErrors.cs | ||
index ed41bb43b..1df996dd0 100644 | ||
--- b/AwsCryptographyPrimitives/runtimes/net/Generated/CollectionOfErrors.cs | ||
+++ a/AwsCryptographyPrimitives/runtimes/net/Generated/CollectionOfErrors.cs | ||
@@ -8,9 +8,18 @@ namespace AWS.Cryptography.Primitives | ||
public class CollectionOfErrors : Exception | ||
{ | ||
public readonly System.Collections.Generic.List<Exception> list; | ||
- public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message) { this.list = list; } | ||
+ public CollectionOfErrors(System.Collections.Generic.List<Exception> list, string message) : base(message + $"\n List: \n{ListAsString(list)}") { this.list = list; } | ||
public CollectionOfErrors(string message) : base(message) { this.list = new System.Collections.Generic.List<Exception>(); } | ||
public CollectionOfErrors() : base("CollectionOfErrors") { this.list = new System.Collections.Generic.List<Exception>(); } | ||
+ | ||
+ private static string ListAsString(List<Exception> list) | ||
+ { | ||
+ if (list.Count < 1) return ""; | ||
+ string[] msgArr = new string[list.Count]; | ||
+ for (int i = 0; i < list.Count; i++) | ||
+ msgArr[i] = $"{list[i].GetType().Name} :: {list[i].Message}"; | ||
+ return String.Join("\n\t", msgArr); | ||
+ } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We are not importing System.Collections.Generic.List
Here and other places
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.
See aws/aws-encryption-sdk#728 (comment)
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.
We are missing a import here. Thats why its a blocking comment.
For example: when I try to run this (below) it works but if I remove
using System.Collections.Generic
it will give me an error.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.
Also, I guess the CI is passing because it only checks for
output.Failure?
but notoutput.error.TypeOfError?
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.
Yes, you nailed it.
I got it to work for one of the three PRs, and did not verify across all three repos.
Great catch.