Search code examples
c#stylecop

Hosting StyleCop in a Custom Environment


I want to host StyleCop in a Custom Environment, the sample code provided in SDK uses this foreach(string myProject in this.myProjects). String doesn't have properties like Path.GetHashCode() and FilesToAnalyze, does anyone knows what is this.myProjects?

List<CodeProject> projects = new List<CodeProject>();    

// what is this.myProject?
foreach (string myProject in this.myProjects)
{
     CodeProject project = new CodeProject(
         myProject.Path.GetHashCode(), myProject.Path, configuration);

    // Add each source file to this project.
    foreach (string sourceFilePath in myProject.FilesToAnalyze)
    {
        console.Core.Environment.AddSourceCode(project, sourceFilePath, null);
    }

    projects.Add(project);
}

Solution

  • After looking at the example in the SDK I think myProject is just a placeholder to indicate how to construct a CodeProject instance.

    If you want you can define a class as shown below or keep the root path and files to analyze in a different data structure.

    public class MyProject
    {
        public string Path { get { ... } }
    
        public IEnumerable<string> FilesToAnalyze { get { ... } }
    }