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

extracting some non-controversial changes to be merged first for clea… #3517

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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,10 +9,8 @@ public class AutocadSelectionBinding : ISelectionBinding
{
private const string SELECTION_EVENT = "setSelection";

private readonly List<Document> _visitedDocuments = new();

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

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

public AutocadSelectionBinding(IBridge parent)
Expand All @@ -26,9 +24,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 +47,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 @@ -18,7 +18,7 @@ namespace Speckle.Connectors.Autocad.Bindings;

public sealed class AutocadSendBinding : ISendBinding
{
public string Name { get; } = "sendBinding";
public string Name => "sendBinding";
public SendBindingUICommands Commands { get; }
public IBridge Parent { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace Speckle.Connectors.Revit.Bindings;
internal abstract class RevitBaseBinding : IBinding
Copy link
Member

Choose a reason for hiding this comment

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

I don't know why we have it at all but it's ok.

{
// POC: name and bridge might be better for them to be protected props?
public string Name { get; protected set; }
public IBridge Parent { get; protected set; }
public string Name { get; }
public IBridge Parent { get; }

protected readonly DocumentModelStore Store;
protected readonly RevitContext RevitContext;

public RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext)
protected RevitBaseBinding(string name, DocumentModelStore store, IBridge bridge, RevitContext revitContext)
{
Name = name;
Parent = bridge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public class RhinoBasicConnectorBinding : IBasicConnectorBinding
{
public string Name { get; set; } = "baseBinding";
public IBridge Parent { get; set; }
public string Name => "baseBinding";
public IBridge Parent { get; }
public BasicConnectorBindingCommands Commands { get; }

private readonly DocumentModelStore _store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public class RhinoReceiveBinding : IReceiveBinding
{
public string Name { get; set; } = "receiveBinding";
public IBridge Parent { get; set; }
public string Name => "receiveBinding";
public IBridge Parent { get; }

private readonly CancellationManager _cancellationManager;
private readonly DocumentModelStore _store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace Speckle.Connectors.Rhino7.Bindings;

public sealed class RhinoSendBinding : ISendBinding
{
public string Name { get; } = "sendBinding";
public string Name => "sendBinding";
public SendBindingUICommands Commands { get; }
public IBridge Parent { get; set; }
public IBridge Parent { get; }

private readonly DocumentModelStore _store;
private readonly RhinoIdleManager _idleManager;
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Speckle.Connectors.DUI.Bindings;

public class AccountBinding : IBinding
{
public string Name { get; set; } = "accountsBinding";
public IBridge Parent { get; private set; }
public string Name => "accountsBinding";
public IBridge Parent { get; }

public AccountBinding(IBridge bridge)
{
Expand Down
4 changes: 2 additions & 2 deletions DUI3-DX/DUI3/Speckle.Connectors.DUI/Bindings/TestBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Speckle.Connectors.DUI.Bindings;
/// </summary>
public class TestBinding : IBinding
{
public string Name { get; set; } = "testBinding";
public IBridge Parent { get; private set; }
public string Name => "testBinding";
public IBridge Parent { get; }

public TestBinding(IBridge bridge)
{
Expand Down
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
Loading