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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b2b3bd0
Added MalformedContext error to OpenError, ChannelError and ResolveError
bingenito Nov 6, 2023
f5eddd2
Updated definition of the instrument context type to include optional…
bingenito Nov 7, 2023
d5c2b04
Added MalformedContext error to OpenError, ChannelError and ResolveError
bingenito Nov 6, 2023
f01ab52
Updated definition of the instrument context type to include optional…
bingenito Nov 7, 2023
74016c7
Update Chart otherConfig to array of Context
bingenito Jul 15, 2024
a00d372
Correct inconsistent casing of fdc3.timeRange
bingenito Jul 15, 2024
9e64b3e
Update Chart tests to pass aray of Context
bingenito Jul 15, 2024
8d7cdc7
Rename ChatInitSettings.InitMessage to Message
bingenito Jul 15, 2024
414a9a8
Fix tests to use valid email and rename Fdsid to FDS_ID
bingenito Jul 15, 2024
639b5a0
Update schema version on tests
bingenito Jul 15, 2024
8b6cf5a
Merge branch 'fdc3-2_1' of https://github.com/bingenito/fdc3-dotnet i…
bingenito Jul 15, 2024
606fc52
Add TransactionResult context type
bingenito Jul 16, 2024
8cea70d
Add TransactionResultStatus helper static string values
bingenito Jul 16, 2024
5c600df
Add Action context type
bingenito Jul 16, 2024
5c95a62
Update version to prepare for 2.1.0 beta 1
bingenito Jul 17, 2024
d59928a
Add ChatRoom context type
bingenito Jul 17, 2024
2f803ad
Ignore obsolete warnings in tests as members still tested
bingenito Jul 19, 2024
9985b46
Add ChatSearchCriteria context type
bingenito Jul 19, 2024
905a4b5
Fix warnings
bingenito Jul 19, 2024
1ec3fd9
Add mising context Type property tests
bingenito Jul 19, 2024
ba7180a
Add Message context type
bingenito Jul 19, 2024
483ed1f
Add ChatMessage context type
bingenito Jul 19, 2024
616aa94
Update ChatInitSettings to use defined types
bingenito Jul 19, 2024
01dded7
Mark AppD displayName as obsolete
bingenito Jul 19, 2024
da43598
Mark AppD App Name as obsolete
bingenito Jul 19, 2024
084d350
Mark AppD App CustomConfig as obsolete
bingenito Jul 19, 2024
5e1c370
Fix AppD Interop AppChannel to use ID instead of Name
bingenito Jul 19, 2024
c196708
Changer Chart OtherConfig from array to IEnumerable
bingenito Jul 19, 2024
b6331db
Fix build warnings
bingenito Jul 29, 2024
914ecee
Add back ctor including obsolete members
bingenito Jul 29, 2024
ce68a38
Remove uncessary imports
bingenito Jul 29, 2024
f13c648
Add context type map entries for new context types
bingenito Jul 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionPrefix>2.1.0</VersionPrefix>
<VersionSuffix>beta.1</VersionSuffix>
<Company>Morgan Stanley</Company>
<Authors>Morgan Stanley</Authors>
<Copyright>Copyright 2023 Morgan Stanley</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

public Task<IListener> AddIntentListener<T>(string intent, IntentHandler<T> handler) where T : IContext
Expand Down
12 changes: 6 additions & 6 deletions src/Fdc3.AppDirectory/AppChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public class AppChannel
/// <summary>
/// Initializes a new instance of the <see cref="AppChannel"/> class.
/// </summary>
/// <param name="name">The name</param>
/// <exception cref="ArgumentNullException">Exception if name is null</exception>
public AppChannel(string name)
/// <param name="id">The ID of the App Channel</param>
/// <exception cref="ArgumentNullException">Exception if ID is null</exception>
public AppChannel(string id)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
ID = id ?? throw new ArgumentNullException(nameof(id));
}
/// <summary>
/// The name of the App Channel.
/// The ID of the App Channel.
/// </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.


/// <summary>
/// A description of how the channel is used.
Expand Down
7 changes: 6 additions & 1 deletion src/Fdc3.AppDirectory/Fdc3App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ public class Fdc3App
public Fdc3App(string appId, string name, AppType type, object details)
{
AppId = appId ?? throw new ArgumentNullException(nameof(appId));
#pragma warning disable CS0618 // Type or member is obsolete
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.

Type = type;
Details = details ?? throw new ArgumentNullException(nameof(details));
}

/// <summary>
/// The unique application identifier located within a specific application directory instance.
/// </summary>
Expand All @@ -43,7 +46,8 @@ public Fdc3App(string appId, string name, AppType type, object details)
/// for multiple versions of the same app. The same appName could occur in other directories.
/// We are not currently specifying app name conventions in the document.
/// </summary>
public string Name { get; set; }
[Obsolete("Use `AppId` to identify apps and `Title` for their display names.")]
public string? Name { get; set; }

/// <summary>
/// The technology type that is used to launch and run the application.
Expand Down Expand Up @@ -147,6 +151,7 @@ public Fdc3App(string appId, string name, AppType type, object details)
/// <summary>
/// An optional set of name value pairs that can be used to deliver custom data from an App Directory to a launcher.
/// </summary>
[Obsolete]
public Dictionary<string, string>? CustomConfig { get; set; }

/// <summary>
Expand Down
7 changes: 5 additions & 2 deletions src/Fdc3.AppDirectory/IntentMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public class IntentMetadata : IIntentMetadata
/// <param name="displayName">The displayName</param>
/// <param name="contexts">The contexts</param>
/// <exception cref="ArgumentNullException">Exception contexts is null</exception>
public IntentMetadata(string name, string displayName, IEnumerable<string> contexts)
public IntentMetadata(string name, string displayName, IEnumerable<string> contexts)
{
Name = name;
#pragma warning disable CS0618 // Type or member is obsolete
DisplayName = displayName;
#pragma warning restore CS0618 // Type or member is obsolete
Contexts = contexts ?? throw new ArgumentNullException(nameof(contexts));
}

Expand All @@ -44,7 +46,8 @@ public IntentMetadata(string name, string displayName, IEnumerable<string> conte
/// <summary>
/// An optional display name for the intent that may be used in UI instead of the name.
/// </summary>
public string DisplayName { get; set; }
[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.")]
public string? DisplayName { get; set; }

/// <summary>
/// A comma separated list of the types of contexts the intent offered by the application
Expand Down
5 changes: 5 additions & 0 deletions src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public override string ConvertName(string name)
case "SEDOL":
case "LEI":
return name;
case "TextPlain":
return "text/plain";
case "TextMarkdown":
return "text/markdown";

bingenito marked this conversation as resolved.
Show resolved Hide resolved
default:
return CamelCase.ConvertName(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public override string GetPropertyName(string name, bool hasSpecifiedName)
case "SEDOL":
case "LEI":
return name;
case "TextPlain":
return "text/plain";
case "TextMarkdown":
return "text/markdown";

default:
return base.GetPropertyName(name, hasSpecifiedName);
Expand Down
34 changes: 34 additions & 0 deletions src/Fdc3/Context/Action.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

namespace Finos.Fdc3.Context
{
public class Action : Context, IContext
{
public Action(string title, IContext context, string? intent, IAppIdentifier? app = null, object? id = null, string? name = null)
: base(ContextTypes.Action, id, name)
{
this.Title = title;
this.Context = context;
this.Intent = intent;
this.App = app;
}

public string Title { get; private set; }
public IContext Context { get; private set; }
public string? Intent { get; private set; }
public IAppIdentifier? App { get; private set; }

}
}
6 changes: 4 additions & 2 deletions src/Fdc3/Context/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
* and limitations under the License.
*/

using System.Collections.Generic;

namespace Finos.Fdc3.Context
{
public class Chart : Context, IContext
{
public Chart(Instrument[] instruments, TimeRange? range = null, object? otherConfig = null, string? style = null, object? id = null, string? name = null)
public Chart(Instrument[] instruments, TimeRange? range = null, IEnumerable<IContext>? otherConfig = null, string? style = null, object? id = null, string? name = null)
: base(ContextTypes.Chart, id, name)
{
this.Instruments = instruments;
Expand All @@ -27,7 +29,7 @@ public Chart(Instrument[] instruments, TimeRange? range = null, object? otherCon

public Instrument[] Instruments { get; set; }
public TimeRange? Range { get; set; }
public object? OtherConfig { get; set; }
public IEnumerable<IContext>? OtherConfig { get; set; }
public string? Style { get; set; }

object? IContext<object>.ID => base.ID;
Expand Down
17 changes: 13 additions & 4 deletions src/Fdc3/Context/ChatInitSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@ namespace Finos.Fdc3.Context
{
public class ChatInitSettings : Context, IContext
{
public ChatInitSettings(ContactList? members = null, string? initMessage = null, string? chatName = null, object? options = null, object? id = null, string? name = null)
public ChatInitSettings(ContactList? members = null, Message? message = null, string? chatName = null, ChatInitSettingsOptions? options = null, object? id = null, string? name = null)
: base(ContextTypes.ChatInitSettings, id, name)
{
this.Members = members;
this.InitMessage = initMessage;
this.Message = message;
this.ChatName = chatName;
this.Options = options;
}

public string? ChatName { get; set; }
public string? InitMessage { get; set; }
public Message? Message { get; set; }
public ContactList? Members { get; set; }
public object? Options { get; set; }
public ChatInitSettingsOptions? Options { get; set; }

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 bool? GroupRecipients { get; set; }
public bool? IsPublic { get; set; }
public bool? AllowHistoryBrowsing { get; set; }
public bool? AllowMessageCopy { get; set; }
public bool? AllowAddUser { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/Fdc3/Context/ChatMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

namespace Finos.Fdc3.Context
{
public class ChatMessage : Context, IContext, IRecipient
{
public ChatMessage(ChatRoom chatRoom, Message message, object? id = null, string? name = null)
: base(ContextTypes.ChatMessage, id, name)
{
this.ChatRoom = chatRoom;
this.Message = message;
}

public ChatRoom ChatRoom { get; set; }
public Message Message { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/Fdc3/Context/ChatRoom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

namespace Finos.Fdc3.Context
{
public class ChatRoom : Context, IContext, IRecipient
{
public ChatRoom(object id, string providerName, string? url = null, string? name = null)
: base(ContextTypes.ChatRoom, id, name)
{
this.ProviderName = providerName;
this.Url = url;
}

public string ProviderName { get; set; }
public string? Url { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/Fdc3/Context/ChatSearchCriteria.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Morgan Stanley makes this available to you under the Apache License,
* Version 2.0 (the "License"). You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.
*
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. Unless required by applicable law or agreed
* to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

using System.Collections;

namespace Finos.Fdc3.Context
{
public class ChatSearchCriteria : Context, IContext
{
public ChatSearchCriteria(IEnumerable criteria, object? id = null, string? name = null)
: base(ContextTypes.ChatSearchCriteria, id, name)
{
this.Criteria = criteria;
}

public IEnumerable Criteria { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Fdc3/Context/Contact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
}
14 changes: 13 additions & 1 deletion src/Fdc3/Context/ContextTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,50 @@ namespace Finos.Fdc3.Context
{
public static class ContextTypes
{
public static readonly string Action = "fdc3.action";
public static readonly string Chart = "fdc3.chart";
public static readonly string ChatInitSettings = "fdc3.chat.initSettings";
public static readonly string ChatMessage = "fdc3.chat.message";
public static readonly string ChatRoom = "fdc3.chat.room";
public static readonly string ChatSearchCriteria = "fdc3.chat.searchCriteria";
public static readonly string Contact = "fdc3.contact";
public static readonly string ContactList = "fdc3.contactList";
public static readonly string Country = "fdc3.country";
public static readonly string Currency = "fdc3.currency";
public static readonly string Email = "fdc3.email";
public static readonly string Instrument = "fdc3.instrument";
public static readonly string InstrumentList = "fdc3.instrumentList";
public static readonly string Message = "fdc3.message";
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.

{
{ ContextTypes.Action, typeof(Action) },
{ ContextTypes.Chart, typeof(Chart) },
{ ContextTypes.ChatInitSettings, typeof(ChatInitSettings) },
{ ContextTypes.ChatMessage, typeof(ChatMessage) },
{ ContextTypes.ChatRoom, typeof(ChatRoom) },
{ ContextTypes.ChatSearchCriteria, typeof(ChatSearchCriteria) },
{ ContextTypes.Contact, typeof(Contact) },
{ ContextTypes.ContactList, typeof(ContactList) },
{ ContextTypes.Country, typeof(Country) },
{ ContextTypes.Currency, typeof(Currency) },
{ ContextTypes.Email, typeof(Email) },
{ ContextTypes.Instrument, typeof(Instrument) },
{ ContextTypes.InstrumentList, typeof(InstrumentList) },
{ ContextTypes.Message, typeof(Message) },
{ ContextTypes.Nothing, typeof(Nothing) },
{ ContextTypes.Organization, typeof(Organization) },
{ ContextTypes.Portfolio, typeof(Portfolio) },
{ ContextTypes.Position, typeof(Position) },
{ ContextTypes.TimeRange, typeof(TimeRange) },
{ ContextTypes.TransactionResult, typeof(TransactionResult) },
{ ContextTypes.Valuation, typeof(Valuation) },
};

Expand Down
10 changes: 10 additions & 0 deletions src/Fdc3/Context/Instrument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public Instrument(InstrumentID? id = null, string? name = null)
{
}

public MarketSource? Market { get; set; }

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

Expand All @@ -36,4 +38,12 @@ public class InstrumentID
public string? SEDOL { get; set; }
public string? Ticker { get; set; }
}

public class MarketSource
{
public string? BBG { get; set; }
public string? COUNTRY_ISOALPHA2 { get; set; }
public string? MIC { get; set; }
public string? Name { get; set; }
}
}
Loading