Skip to content

Commit

Permalink
fix(All): Solution pass to fix formatting warnings (#3068)
Browse files Browse the repository at this point in the history
* chore: Silence Bentley and AdvanceSteel warnings on CI

* fix(rvt): Remove space in `Partial Classes` folder

* fix(tekla): Remove space from `Partial Classes` folder

* fix(dyn): REVERT THIS AT THE END. Fix dynamo build on mac for cleanup

* chore(all): Run csharpier for entire monorepo

* fix(IDE0161): File-scoped namespaces

* fix(IDE0090): 'new' expression can be simplified

* fix(IDE0022): Use block body for method

* Revert "fix(IDE0022): Use block body for method"

This reverts commit 8bb9b7e.

* feat: Expression body for methods is suggestion now

* chore: Enforce husky setup on restore

* fix: PEBKAC 🤦🏼‍♂️

* fix(all): IDE0011

* Warnings for our first set of warnings

* fix(all): IDE0011

* feat(ci): Enforce csharpier formatting

* fix(ci): Wrong yaml indent and format

* fix(tests): IsDesktopBuild passed to tests in core

* fix(ci): Disable auto pre-commit hook install

* removed accidental push of warning as error

* Revert "fix(dyn): REVERT THIS AT THE END. Fix dynamo build on mac for cleanup"

This reverts commit 0658b36.

---------

Co-authored-by: Jedd Morgan <[email protected]>
  • Loading branch information
AlanRynne and JR-Morgan authored Nov 28, 2023
1 parent 0c0360d commit 7397e53
Show file tree
Hide file tree
Showing 852 changed files with 60,133 additions and 50,614 deletions.
6 changes: 6 additions & 0 deletions .circleci/scripts/config-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ commands:
name: << parameters.title >>
command: $HOME/.dotnet/dotnet test << parameters.project >>
-c Release
-p:IsDesktopBuild=false
--logger:"junit;LogFileName={assembly}.results.xml"
--results-directory=TestResults
--collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
Expand All @@ -93,6 +94,11 @@ jobs: # Each project will have individual jobs for each specific task it has to
command: |
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel Current
$HOME/.dotnet/dotnet --version
- run:
name: Enforce formatting
command: |
$HOME/.dotnet/dotnet tool restore
$HOME/.dotnet/dotnet csharpier --check .
- run:
name: Build SDK Projects
command: |
Expand Down
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none

# Prefer method-like constructs to have a block body
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_operators = true:suggestion

Expand Down Expand Up @@ -212,6 +212,7 @@ dotnet_diagnostic.ide0046.severity = suggestion # Use conditional expression for
dotnet_diagnostic.ide0078.severity = suggestion # Use pattern matching: Subjective
dotnet_diagnostic.ide0260.severity = suggestion # Use pattern matching: Subjective
dotnet_diagnostic.ide0058.severity = suggestion # Remove unnecessary expression value: Subjective
dotnet_diagnostic.ide0022.severity = suggestion # Use expression body for method: Subjective

# Maintainability rules
dotnet_diagnostic.ca1501.severity = warning # Avoid excessive inheritance
Expand Down
2 changes: 1 addition & 1 deletion All.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantVirtualModifier/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantWithCancellation/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReferenceEqualsWithValueType/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveRedundantBraces/@EntryIndexedValue">HINT</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RemoveRedundantBraces/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RequiredBaseTypesConflict/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RequiredBaseTypesDirectConflict/@EntryIndexedValue">SUGGESTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RequiredBaseTypesIsNotInherited/@EntryIndexedValue">SUGGESTION</s:String>
Expand Down
23 changes: 23 additions & 0 deletions Automate/Speckle.Automate.Sdk/AutomationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ public async Task<Base> ReceiveVersion()
.Receive(commit.referencedObject, serverTransport, memoryTransport)
.ConfigureAwait(false);
if (commitRootObject == null)
{
throw new Exception("Commit root object was null");
}

Console.WriteLine(
$"It took {Elapsed.TotalSeconds} seconds to receive the speckle version {AutomationRunData.VersionId}"
);
Expand All @@ -87,10 +90,13 @@ public async Task<Base> ReceiveVersion()
public async Task<string> CreateNewVersionInProject(Base rootObject, string branchName, string versionMessage = "")
{
if (branchName == AutomationRunData.BranchName)
{
throw new ArgumentException(
$"The target model: {branchName} cannot match the model that triggered this automation: {AutomationRunData.ModelId}/{AutomationRunData.BranchName}",
nameof(branchName)
);
}

var rootObjectId = await Operations
.Send(rootObject, new List<ITransport> { serverTransport, memoryTransport }, useDefaultCache: false)
.ConfigureAwait(false);
Expand Down Expand Up @@ -121,11 +127,19 @@ public void SetContextView(List<string>? resourceIds = null, bool includeSourceM
{
var linkResources = new List<string>();
if (includeSourceModelVersion)
{
linkResources.Add($@"{AutomationRunData.ModelId}@{AutomationRunData.VersionId}");
}

if (resourceIds is not null)
{
linkResources.AddRange(resourceIds);
}

if (linkResources.Count == 0)
{
throw new Exception("We do not have enough resource ids to compose a context view");
}

AutomationResult.ResultView = $"/projects/{AutomationRunData.ProjectId}/models/{string.Join(",", linkResources)}";
}
Expand Down Expand Up @@ -204,7 +218,10 @@ mutation ReportFunctionRunStatus(
public async Task StoreFileResult(string filePath)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException("The given file path doesn't exist", fileName: filePath);
}

using var formData = new MultipartFormDataContent();

var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
Expand All @@ -221,7 +238,10 @@ public async Task StoreFileResult(string filePath)
Console.WriteLine("RESPONSE - " + responseString);
var uploadResponse = JsonConvert.DeserializeObject<BlobUploadResponse>(responseString);
if (uploadResponse.UploadResults.Count != 1)
{
throw new Exception("Expected one upload result.");
}

AutomationResult.Blobs.AddRange(uploadResponse.UploadResults.Select(r => r.BlobId));
}

Expand All @@ -235,7 +255,10 @@ private void _markRun(AutomationStatus status, string? statusMessage)

var msg = $"Automation run {statusValue} after {duration} seconds.";
if (statusMessage is not null)
{
msg += $"\n{statusMessage}";
}

Console.WriteLine(msg);
}

Expand Down
8 changes: 7 additions & 1 deletion Automate/Speckle.Automate.Sdk/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ TInput inputs
{
await automateFunction(automationContext, inputs).ConfigureAwait(false);
if (automationContext.RunStatus is not ("FAILED" or "SUCCEEDED"))
{
automationContext.MarkRunSuccess(
"WARNING: Automate assumed a success status, but it was not marked as so by the function."
);
}
}
catch (Exception ex)
{
Expand All @@ -39,8 +41,10 @@ TInput inputs
finally
{
if (automationContext.ContextView is null)
{
automationContext.SetContextView();

}

await automationContext.ReportRunStatus().ConfigureAwait(false);
}
return automationContext;
Expand Down Expand Up @@ -116,7 +120,9 @@ public static async Task<int> Main<TInput>(string[] args, Func<AutomationContext
.ConfigureAwait(false);

if (context.RunStatus != AutomationStatusMapping.Get(AutomationStatus.Succeeded))
{
returnCode = 1; // Flag run as failed.
}
},
speckleProjectDataArg,
functionInputsArg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public static async Task Run(AutomationContext automateContext, TestFunctionInpu
if (versionRootObject.speckle_type == testFunctionInputs.ForbiddenSpeckleType)
{
if (versionRootObject.id is null)
{
throw new InvalidOperationException("Cannot operate on objects without their ids");
}

automateContext.AttachErrorToObjects(
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,36 @@
using System.Threading;
using System.Threading.Tasks;

namespace Archicad.Communication
namespace Archicad.Communication;

internal class AsyncCommandProcessor
{
internal class AsyncCommandProcessor
{
#region --- Fields ---
#region --- Fields ---

public static AsyncCommandProcessor Instance { get; } = new AsyncCommandProcessor();

public static AsyncCommandProcessor Instance { get; } = new AsyncCommandProcessor();
#endregion

#endregion
#region --- Functions ---

#region --- Functions ---
public static Task<TResult>? Execute<TResult>(Commands.ICommand<TResult> command)
where TResult : class
{
return Execute(command, CancellationToken.None);
}

public static Task<TResult>? Execute<TResult>(Commands.ICommand<TResult> command)
where TResult : class
public static Task<TResult>? Execute<TResult>(Commands.ICommand<TResult> command, CancellationToken token)
where TResult : class
{
try
{
return Execute(command, CancellationToken.None);
return Task.Run(command.Execute, token);
}

public static Task<TResult>? Execute<TResult>(Commands.ICommand<TResult> command, CancellationToken token)
where TResult : class
catch (Exception e)
{
try
{
return Task.Run(command.Execute, token);
}
catch (Exception e)
{
return null;
}
return null;
}

#endregion
}

#endregion
}
98 changes: 49 additions & 49 deletions ConnectorArchicad/ConnectorArchicad/Communication/CommandRequest.cs
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
using Speckle.Newtonsoft.Json;
using Speckle.Newtonsoft.Json;

namespace Archicad.Communication
namespace Archicad.Communication;

[JsonObject(MemberSerialization.OptIn)]
internal sealed class AddOnCommandRequest<T>
where T : class
{
#region --- Classes ---

[JsonObject(MemberSerialization.OptIn)]
internal sealed class AddOnCommandRequest<T> where T : class
private sealed class AddonCommandID
{
#region --- Classes ---

[JsonObject(MemberSerialization.OptIn)]
private sealed class AddonCommandID
{
#region --- Fields ---

[JsonProperty("commandName")]
public string CommandName { get; private set; }
#region --- Fields ---

[JsonProperty("commandNamespace")]
public string CommandNamespace { get; } = "Speckle";
[JsonProperty("commandName")]
public string CommandName { get; private set; }

#endregion
[JsonProperty("commandNamespace")]
public string CommandNamespace { get; } = "Speckle";

#region --- Ctor \ Dtor ---
#endregion

public AddonCommandID(string commandName)
{
CommandName = commandName;
}
#region --- Ctor \ Dtor ---

#endregion
public AddonCommandID(string commandName)
{
CommandName = commandName;
}

[JsonObject(MemberSerialization.OptIn)]
private sealed class AddonCommandParameters
{
#region --- Fields ---
#endregion
}

[JsonProperty("addOnCommandId")]
private AddonCommandID Id { get; set; }
[JsonObject(MemberSerialization.OptIn)]
private sealed class AddonCommandParameters
{
#region --- Fields ---

[JsonProperty("addOnCommandParameters")]
private T Parameters { get; set; }
[JsonProperty("addOnCommandId")]
private AddonCommandID Id { get; set; }

#endregion
[JsonProperty("addOnCommandParameters")]
private T Parameters { get; set; }

#region --- Ctor \ Dtor ---
#endregion

public AddonCommandParameters(string commandName, T parameters)
{
Id = new AddonCommandID(commandName);
Parameters = parameters;
}
#region --- Ctor \ Dtor ---

#endregion
public AddonCommandParameters(string commandName, T parameters)
{
Id = new AddonCommandID(commandName);
Parameters = parameters;
}

#endregion
}

#region --- Fields ---
#endregion

[JsonProperty("command")]
private string Command { get; } = "API.ExecuteAddOnCommand";
#region --- Fields ---

[JsonProperty("parameters")]
private AddonCommandParameters Parameters { get; set; }
[JsonProperty("command")]
private string Command { get; } = "API.ExecuteAddOnCommand";

#endregion
[JsonProperty("parameters")]
private AddonCommandParameters Parameters { get; set; }

#region --- Ctor \ Dtor ---
#endregion

public AddOnCommandRequest(string commandName, T requestParams)
{
Parameters = new AddonCommandParameters(commandName, requestParams);
}
#region --- Ctor \ Dtor ---

#endregion
public AddOnCommandRequest(string commandName, T requestParams)
{
Parameters = new AddonCommandParameters(commandName, requestParams);
}

#endregion
}
Loading

0 comments on commit 7397e53

Please sign in to comment.