Skip to content

Conversation

@QilongTang
Copy link
Contributor

@QilongTang QilongTang commented May 17, 2020

Please Note:

  1. Before submitting the PR, please review How to Contribute to Dynamo
  2. Dynamo Team will meet 1x a month to review PRs found on Github (Issues will be handled separately)
  3. PRs will be reviewed from oldest to newest
  4. If a reviewed PR requires changes by the owner, the owner of the PR has 30 days to respond. If the PR has seen no activity by the next session, it will be either closed by the team or depending on its utility will be taken over by someone on the team
  5. PRs should use either Dynamo's default PR template or one of these other template options in order to be considered for review.
  6. PRs that do not have one of the Dynamo PR templates completely filled out with all declarations satisfied will not be reviewed by the Dynamo team.
  7. PRs made to the DynamoRevit repo will need to be cherry-picked into all the DynamoRevit Release branches that Dynamo supports. Contributors will be responsible for cherry-picking their reviewed commits to the other branches after a LGTM label is added to the PR.

Purpose

Fix some new code smells brought in last week..

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.

Reviewers

@DynamoDS/dynamo

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

}

public static ShaderDescription VertexShaderDynamoMeshDescription = new ShaderDescription(nameof(VertexShaderDynamoMeshDescription), ShaderStage.Vertex,
public static readonly ShaderDescription VertexShaderDynamoMeshDescription = new ShaderDescription(nameof(VertexShaderDynamoMeshDescription), ShaderStage.Vertex,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

API breaking, but team agreed on Helix related work

}

public static ShaderDescription PixelShaderDynamoMeshDescription = new ShaderDescription(nameof(PixelShaderDynamoMeshDescription), ShaderStage.Pixel,
public static readonly ShaderDescription PixelShaderDynamoMeshDescription = new ShaderDescription(nameof(PixelShaderDynamoMeshDescription), ShaderStage.Pixel,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here

{
geometryModels = Element3DDictionary
.Where(x => x.Key.Contains(node.AstIdentifierGuid) && x.Value as Element3D != null).ToArray();
.Where(x => x.Key.Contains(node.AstIdentifierGuid) && x.Value is Element3D).ToArray();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

SQ has been back and forth about this, which made me think we may not need this type check at all

if (!pkgResponse.success)
{
throw new Exception(pkgResponse.message);
throw new ApplicationException(pkgResponse.message);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please, no more System Exception thrown by user code :)

Copy link
Collaborator

@mmisol mmisol May 19, 2020

Choose a reason for hiding this comment

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

@QilongTang I know this has been merged already, but as a future reference, ApplicationException is not recommended to be used anymore. From https://docs.microsoft.com/en-us/dotnet/api/system.applicationexception?view=netcore-3.1:

You should derive custom exceptions from the Exception class rather than the ApplicationException class. You should not throw an ApplicationException exception in your code, and you should not catch an ApplicationException exception unless you intend to re-throw the original exception.

I think in this particular case, the most appropriate fix would be to throw a PackageManagerException which derives from Exception.

/// <returns> true if the element was found </returns>
public static bool GetFirstNonArrayStackValue(StackValue svArray, ref StackValue sv, RuntimeCore runtimeCore)
{
RuntimeMemory rmem = runtimeCore.RuntimeMemory;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused local var

protected PythonNodeBase(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(inPorts, outPorts)
{
ArgumentLacing = LacingStrategy.Disabled;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Constructors should be grouped near

public void GettingNodeNameDoesNotTriggerPropertyChangeCycle()
{
//add a node
var numNode = new CoreNodeModels.Input.DoubleInput { X = 100, Y = 100 };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ModeBase.X is obsolete, seems here we do not really need positions to be set

/// </summary>
/// <param name="packageDownloadHandle">package download handle</param>
/// <param name="downloadPath">package download path</param>
internal void InstallStateCheck(PackageDownloadHandle packageDownloadHandle, string downloadPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing: As we are assigning the package state in this method, may be we can call it something like SetPackageState.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reddyashish Make sense. Let me update!

@reddyashish
Copy link
Contributor

Looks good to me @QilongTang.

@QilongTang
Copy link
Contributor Author

@reddyashish Addressed your comments. Merging.

@QilongTang QilongTang merged commit 358cd39 into master May 19, 2020
@QilongTang QilongTang deleted the CodeSmells branch May 19, 2020 00:17
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.

4 participants