Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 106507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:36:27+00:00 2026-05-11T01:36:27+00:00

I have a data structure that represents C# code like this: class Namespace: string

  • 0

I have a data structure that represents C# code like this:

class Namespace:     string Name;     List<Class> Classes;  class Class:     string Name;     List<Property> Properties;     List<Method> Methods;     List<Method> Constructors;     List<Field> Fields;     List<Class> InnerClasses;     Class Parent;     List<Interface> Implements; 

… which I’m building using a simple lexer/parser combination. I need to traverse the tree and apply a large set of rules (more than 3000). Rules run when encountering different (and quite complex) patterns in the tree. For example, there’s a rule that runs when a class only implements interfaces in the same assembly.

My original naïve implementation iterates over each rule and then each rule traverses the tree looking for its specific pattern. Of course, this takes quite a lot of time, even with a small amount of source code.

I suppose this could be likened to how antivirus software works, recognizing complex patterns on a large body of binary code.

How would you suggest one implement this kind of software?

EDT: Just like to add: No, I’m not re-implementing FxCop.

Thanks

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:36:28+00:00Added an answer on May 11, 2026 at 1:36 am

    You could try to aggregate your 3000 rules. Some of the 3000, I would guess assume another member of the 3000. Say rule 12 checks ‘a class implements an interface’. Rule 85 might be ‘a class only implements interfaces in the same assembly’. If rule 12 fails, no need to run rule 85 at all.

    This approach (alpha-beta pruning) would either need you to restructure your algorithm to search the class tree, looking for all rules patterns at the same time. Or to stash a record that a previous rule pass has identified that the current rule pass is irrelevant.

    COMMENT: I have a nub level account so i can’t comment directly. Can you give an example of maybe 2 more rules? I am currently thinking your algorithm is 0(n*n) (following copied from a big 0 notation post)

    O(n*log(n)): an algorithm that does some sort of divide and conquer strategy. Hurts for large n. Typical example: merge sort

    O(n*n): a nested loop of some sort. Hurts even with small n. Common with naive matrix calculations. You want to avoid this sort of algorithm if you can.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 60k
  • Answers 60k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Oops, so I have found the answer to my problem:… May 11, 2026 at 9:31 am
  • added an answer The best way is to use the LinqDataSource. Create an… May 11, 2026 at 9:31 am
  • added an answer Seems OK. From the description: SYS_GUID generates and returns a… May 11, 2026 at 9:31 am

Related Questions

I have a data structure that represents C# code like this: class Namespace: string
I have a tree data structure that is L levels deep each node has
Assuming Visual C/C++ 6, I have a complex data structure of 22399 elements that
I have to write a component that re-creates SQL Server tables (structure and data)
I have a set of core, complicated JavaScript data structures/classes that I'd like to
I have the following data structure (a list of lists) [ ['4', '21', '1',
I have a data stream that may contain \r, \n, \r\n, \n\r or any
I have a data tables with this type of setup. Table A AID AName
I have a data warehouse containing typical star schemas, and a whole bunch of
I have a data set whose elements are displayed as rows in a DataGrid.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.