Skip to content

Annotations for class methods that must be executed #3262

Open
@ThunderFrame

Description

@ThunderFrame

Some classes require a member be called before any other usage is allowed, or before an item can be disposed, or if not called - the class isn't being used properly. Sometimes the method can be called internally (by the class itself), and at other times, the consumer of the class needs to invoke the member(s).

@retailcoder suggested a @MustExecute annotation at the procedure level, but that doesn't seem to allow for the variety of times at which a procedure must be called, and by which code.

Timing

  • Must execute after initialization, but before any other member is called
    In the absence of a (suitable) factory method, there may be a requirement that one or more properties be assigned, or methods called, before the class is fully useable.

  • Must execute at least n times after initialization, and before destruction
    For example, a custom collection class must have at least one call to the Add method, or the collection is nothing more than an empty collection. I suppose you could also argue that at least one call to Item or Remove is necessary too.

  • Must execute after all other member calls, and before destruction
    For example, code that consumes a child object must finally invoke child.Dispose before the object is destroyed. Another example might be Class_Terminate must call CleanupDbConnection.

Source of invocation

  • Must be invoked from inside the class
    Might be something as simple as Form_Load must invoke InitializeControls and InitializeDbConnection

  • Must be invoked by consumer of the class
    For example, code that consumes a child object must invoke child.Dispose

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-path-analysisInvolves simulating execution paths / interpreting the user code ..to an extent.discussionenhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-annotationsfeature-inspectionsretriage-v3Issue is deferred until v3 is completed and may be entirely solved by the paradigm shift

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions