Skip to content

Commit

Permalink
extracting some non-controversial changes to be merged first for clea…
Browse files Browse the repository at this point in the history
…ner diff
  • Loading branch information
JR-Morgan committed Jun 17, 2024
1 parent 28656e5 commit 84ce887
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
1 change: 0 additions & 1 deletion Core/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<PackageReference Include="Sentry.Serilog" Version="3.33.0"/>
<PackageReference Include="Serilog" Version="2.12.0"/>
<PackageReference Include="Serilog.Enrichers.ClientInfo" Version="1.3.0"/>
<PackageReference Include="Serilog.Enrichers.GlobalLogContext" Version="3.0.0"/>
<PackageReference Include="Serilog.Exceptions" Version="8.4.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Speckle.Connectors.ArcGIS.Bindings;

public class ArcGISSelectionBinding : ISelectionBinding
{
public string Name { get; } = "selectionBinding";
public IBridge Parent { get; set; }
public string Name => "selectionBinding";
public IBridge Parent { get; }

public ArcGISSelectionBinding(IBridge parent)
{
Expand All @@ -22,7 +22,7 @@ public ArcGISSelectionBinding(IBridge parent)
private void OnSelectionChanged(MapViewEventArgs args)
{
SelectionInfo selInfo = GetSelection();
Parent?.Send(SelectionBindingEvents.SET_SELECTION, selInfo);
Parent.Send(SelectionBindingEvents.SET_SELECTION, selInfo);
}

public SelectionInfo GetSelection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ public class AutocadSelectionBinding : ISelectionBinding
{
private const string SELECTION_EVENT = "setSelection";

private readonly List<Document> _visitedDocuments = new();
public string Name { get; } = "selectionBinding";

public string Name { get; set; } = "selectionBinding";

public IBridge Parent { get; }

Expand All @@ -26,9 +25,9 @@ public AutocadSelectionBinding(IBridge parent)
Application.DocumentManager.DocumentActivated += (sender, e) => OnDocumentChanged(e.Document);
}

private void OnDocumentChanged(Document document) => TryRegisterDocumentForSelection(document);
private void OnDocumentChanged(Document? document) => TryRegisterDocumentForSelection(document);

private void TryRegisterDocumentForSelection(Document document)
private void TryRegisterDocumentForSelection(Document? document)
{
if (document == null)
{
Expand All @@ -49,13 +48,13 @@ private void TryRegisterDocumentForSelection(Document document)
private void OnSelectionChanged()
{
SelectionInfo selInfo = GetSelection();
Parent?.Send(SELECTION_EVENT, selInfo);
Parent.Send(SELECTION_EVENT, selInfo);
}

public SelectionInfo GetSelection()
{
// POC: Will be addressed to move it into AutocadContext! https://spockle.atlassian.net/browse/CNX-9319
Document doc = Application.DocumentManager.MdiActiveDocument;
Document? doc = Application.DocumentManager.MdiActiveDocument;
List<string> objs = new();
List<string> objectTypes = new();
if (doc != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,6 @@
"Serilog": "2.4.0"
}
},
"Serilog.Enrichers.GlobalLogContext": {
"type": "Transitive",
"resolved": "3.0.0",
"contentHash": "IIZcj5mAUVhIl/NTA+YI2KC+sPDzcwvs0ZMHH42jsPfl1a4LVX7ohVpw5UK+e3GxuV3Nv239Il5oM2peUIl44g==",
"dependencies": {
"Serilog": "2.12.0"
}
},
"Serilog.Exceptions": {
"type": "Transitive",
"resolved": "8.4.0",
Expand Down Expand Up @@ -529,7 +521,6 @@
"Sentry.Serilog": "[3.33.0, )",
"Serilog": "[2.12.0, )",
"Serilog.Enrichers.ClientInfo": "[1.3.0, )",
"Serilog.Enrichers.GlobalLogContext": "[3.0.0, )",
"Serilog.Exceptions": "[8.4.0, )",
"Serilog.Sinks.Console": "[4.1.0, )",
"Serilog.Sinks.Seq": "[5.2.2, )",
Expand Down
5 changes: 5 additions & 0 deletions DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/IBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ public interface IBridge
/// <param name="action"> Action to run on main thread.</param>
public void RunOnMainThread(Action action);

/// <param name="eventName"></param>
/// <exception cref="InvalidOperationException">Bridge was not associated with a binding</exception>
public void Send(string eventName);

/// <inheritdoc cref="Send(string)"/>
/// <param name="data">data to store</param>
/// <typeparam name="T"></typeparam>
public void Send<T>(string eventName, T data)
where T : class;
}
8 changes: 8 additions & 0 deletions DUI3-DX/Sdk/Speckle.Connectors.Utils/NotNullExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Speckle.Connectors.Utils;

public static class NotNullExtensions
{
/// <inheritdoc cref="NotNull{T}(T?,string?)"/>
public static async Task<T> NotNull<T>(
this Task<T?> task,
[CallerArgumentExpression(nameof(task))] string? message = null
Expand All @@ -19,6 +20,7 @@ public static async Task<T> NotNull<T>(
return x;
}

/// <inheritdoc cref="NotNull{T}(T?,string?)"/>
public static async Task<T> NotNull<T>(
this Task<T?> task,
[CallerArgumentExpression(nameof(task))] string? message = null
Expand All @@ -33,6 +35,11 @@ public static async Task<T> NotNull<T>(
return x.Value;
}

/// <param name="obj">the object to check for null</param>
/// <param name="paramName">see <see cref="CallerArgumentExpressionAttribute"/></param>
/// <typeparam name="T"><paramref name="obj"/> type</typeparam>
/// <returns>A non null <typeparamref name="T"/> value</returns>
/// <exception cref="ArgumentNullException"><paramref name="obj"/> was null</exception>
public static T NotNull<T>([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null)
where T : class
{
Expand All @@ -43,6 +50,7 @@ public static T NotNull<T>([NotNull] this T? obj, [CallerArgumentExpression(name
return obj;
}

/// <inheritdoc cref="NotNull{T}(T?,string?)"/>
public static T NotNull<T>([NotNull] this T? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null)
where T : struct
{
Expand Down

0 comments on commit 84ce887

Please sign in to comment.