tags:

views:

83

answers:

2

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);
}
+1  A: 

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 { ... } }
}
dtb
You might be right ... but see the first foreach (string myProject in this.myProjects), this indicates that MyProject is collection of string ....
alittlebitofday
@alittlebitofday: As you've already observed, `string` doesn't have a `Path` or `FilesToAnalyze` property. So the example from the SDK won't compile "as is".
dtb
Thanks @dtb ... it worked....
alittlebitofday
A: 

Yes, this is just meant to be a pseudocode example. Your best bet it to go to stylecop.codeplex.com and just look at the actual StyleCop code. There are many examples in the code showing how to host StyleCop.

Jason Allor