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

Update to 2.1 specification #141

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open

Update to 2.1 specification #141

wants to merge 32 commits into from

Conversation

bingenito
Copy link
Member

@bingenito bingenito commented Jul 29, 2024

Update to 2.1. Checklist and work detailed in #74


THIS SOFTWARE IS CONTRIBUTED SUBJECT TO THE TERMS OF THE FINOS CORPORATE CONTRIBUTOR LICENSE AGREEMENT.

THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.

@bingenito bingenito requested a review from a team as a code owner July 29, 2024 16:43
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 81.35593% with 22 lines in your changes missing coverage. Please review.

Project coverage is 77.22%. Comparing base (c783922) to head (f13c648).
Report is 35 commits behind head on main.

Files Patch % Lines
...3.NewtonsoftJson/Serialization/IntentsConverter.cs 50.00% 3 Missing and 2 partials ⚠️
src/Fdc3/IntentMetadata.cs 0.00% 5 Missing ⚠️
src/Fdc3/Context/TransactionResultStatus.cs 0.00% 4 Missing ⚠️
src/Fdc3/Errors.cs 0.00% 3 Missing ⚠️
...c3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs 0.00% 2 Missing ⚠️
src/Fdc3.Json/Serialization/IntentsConverter.cs 66.66% 1 Missing and 1 partial ⚠️
src/Fdc3.AppDirectory/AppChannel.cs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   76.56%   77.22%   +0.66%     
==========================================
  Files          53       62       +9     
  Lines         431      527      +96     
  Branches       44       48       +4     
==========================================
+ Hits          330      407      +77     
- Misses         82       98      +16     
- Partials       19       22       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bingenito bingenito marked this pull request as draft July 29, 2024 17:38
@@ -33,7 +33,7 @@ public DesktopAgent()

public Task<IListener> AddContextListener<T>(string? contextType, ContextHandler<T> handler) where T : IContext
{
return _currentChannel?.AddContextListener<T>(contextType, handler);
return _currentChannel?.AddContextListener<T>(contextType, handler) ?? throw new Exception("Unable to create listener");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a long existing build warning in the example project about possible null return value when the return is declared as non nullable

/// </summary>
public string Name { get; set; }
public string ID { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppChannel Name changed to ID to avoid confusion. This required changes to class and sample json used for deserialization in unit testing.

Name = name ?? throw new ArgumentNullException( nameof(name));
#pragma warning restore CS0618 // Type or member is obsolete
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though Name is marked as obsolete/decomissioned we are still using it. In order to not have build errors in our own code about using obsolete member, disable the warning.

@@ -28,6 +28,6 @@ public class ContactID
{
public string? Email { get; set; }

public string? FdsId { get; set; }
public string? FDS_ID { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was was previously incorrect and is being fied here.


object? IContext<object>.ID => base.ID;
}

public class ChatInitSettingsOptions
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I was so lazy in past implementation of just taking an object. I defined it as a custom type now.

public static readonly string Nothing = "fdc3.nothing";
public static readonly string Organization = "fdc3.organization";
public static readonly string Portfolio = "fdc3.portfolio";
public static readonly string Position = "fdc3.position";
public static readonly string TimeRange = "fdc3.timerange";
public static readonly string TimeRange = "fdc3.timeRange";
public static readonly string TransactionResult = "fdc3.transactionResult";
public static readonly string Valuation = "fdc3.valuation";

public static IDictionary<string, Type> Map = new Dictionary<string, Type>()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those wondering, this is useful for DesktopAgents to use as a mapping when doing deserialization. Based on the context type string on the message, do the lookup here to get the concrete type and then deserialize to that type. Note that this is also public so your desktopagent can add/overwrite in their implementation as they see fit such as mapping to a derived context type rather than the base default.

* and limitations under the License.
*/

namespace Finos.Fdc3.Context
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on standards call. This is being defined as string constants for conditional statements and creating messages as an enum would be serialized to lower case and not be correct. The default serialization for enum is to lower case based on other areas of the api and contexts so to use an enum here would require custom serialization on TransactionResult

@@ -27,6 +29,7 @@ public interface IIntentMetadata
/// <summary>
/// A friendly display name for the intent that should be used to render UI elements.
/// </summary>
string DisplayName { get; }
[Obsolete("Use the intent name for display as display name may vary for each application as it is defined in the app's AppD record.")]
string? DisplayName { get; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete/decommissioned and also changed to nullable

[Fact]
public async Task Message_SerializedJsonMatchesSchema()
{
Message message = new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of how we defined the type with TextPlain/TextMarkdown string properties and the schema validation below will pass if they are serialized to text/plan and text/markdown

@psmulovics
Copy link
Contributor

Any desire if you are already there changing the tests to be async Task instead of async void?

@bingenito
Copy link
Member Author

Any desire if you are already there changing the tests to be async Task instead of async void?

They were changed from async void to async Task to cleanup warnings in preparation for next xunit release.

@bingenito bingenito marked this pull request as ready for review July 29, 2024 18:52
this.Message = message;
}

public string Status { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on TransactionResultStatus on this not being an enum but just a string

public MessageText Text { get; set; }
}

public class MessageText
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom serializer provided in NewtonsoftJson or Json packages correctly round-trip these by changing to text/plan and text/markdown

@kriswest kriswest linked an issue Aug 22, 2024 that may be closed by this pull request
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to FDC3 2.1
4 participants