Naming Conventions

11 posts, 0 answers
  1. Christian
    Christian avatar
    112 posts
    Member since:
    May 2010

    Posted 19 Jan 2012 Link to this post

    Dear Community,

    how can I create a Naming Conventions rule on Methods which match the following mehtod:

    protected void BtnTest_Click (Object sender, EventArgs e)
    {
        ...
    }

    I can't figure out how to configure it.

    Kind regards
    Chrstian
  2. Matt.F
    Matt.F avatar
    12 posts
    Member since:
    Jun 2007

    Posted 19 Jan 2012 Link to this post

    Same here, I disabled the method naming convention as there doesn't seem to be a way to make it match against auto generated / auto even wireup methods like the one you posted. Bit annoying really but there you go.

    Matt
  3. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Jan 2012 Link to this post

    It's a bit sad that event code generated by JC itself doesn't use the Naming Convention settings; if you have Method Parameter naming set to PascalCase and JC generates, for example, an event handler, it always uses camelCase for the parameters.

    --
    Stuart
  4. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 19 Jan 2012 Link to this post

    Hi,

    Currently, you are not able to set a rule that matches the given method name.
    However, we are going to introduce such a rule so that we can cover this case.
    Besides disabling the method naming convention, there is another temporary workaround. You could introduce secondary naming conventions with suffix, for example "_Click" and use PascalCase as a rule.
     JustCode also follows the chosen naming conventions and generates code that matches the chosen convention. Not doing so in "Create Event Invocator" is clearly a bug and we are going to fix it as soon as possible.

    All the best,
    Ivan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Jan 2012 Link to this post

    Ivan,

    Thanks for the update.

    --
    Stuart
  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 23 Jan 2012 Link to this post

    On a related note, adding markup like this ...
    <telerik:RadTreeView runat="server" ID="RadTreeView1" OnNodeClick="RadTreeView1_NodeClick">
    Then using the JC visual aid to create the event results in this...
    public void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    Which JC reports on saying the suggested name is RadTreeView1NodeClick.

    --
    Stuart


  7. James Legan
    James Legan avatar
    54 posts
    Member since:
    Sep 2008

    Posted 23 Jan 2012 Link to this post

    On the subject....

    Is there anyway to use the new Naming Convention feature in clean-up to automaticlly apply the defined naming convention rules to existing code?
  8. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 25 Jan 2012 Link to this post

    Hi,

    @Stuart Hemming - In that case JustCode detects that the event handler that the user typed does not exist. That is why, JustCode suggests to create such a method. However, the user has already specified what the name should be and that takes precedence. We can only show a warning that it does not match the naming convention. It is up to the user whether to change it or not.

    @James Legan - Currently, there is no code cleaning step for the naming conventions. However, there is such an item in our code base and we will consider implementing it.

    Kind regards,
    Ivan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Bill
    Bill avatar
    28 posts
    Member since:
    Apr 2011

    Posted 16 Feb 2012 Link to this post

    The JC Code Style is also enforced on designer-generated files. For example, if you create a new WPF project, you'll get a lot of code style warnings.

    As we have no control over the naming conventions Microsoft uses, JC should NOT be scanning files generated by Visual Studio.

    Because of this, I have disabled all the Code Styles; it is unusable as it is now.
  10. Ivan
    Admin
    Ivan avatar
    106 posts

    Posted 17 Feb 2012 Link to this post

    Hi,

    Thank you for your feedback. You can customize JustCode so it does not show errors or warnings from specific files. Here is a sample demo how to do this: http://screencast.com/t/tiTlDgmMA3.
    JustCode also by default skips designer files.
    If you have any more questions or remarks, please do not hesitate to contact us again!

    Regards,
    Ivan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  11. Bill
    Bill avatar
    28 posts
    Member since:
    Apr 2011

    Posted 17 Feb 2012 Link to this post

    Thanks for the tip; that did the trick. I added the WPF files AssemblyInfo.vb and MyWpfExtension.vb to the exclude file filters.
Back to Top