[mdoc-update] Filename comparison should be OrdinalIgnoreCase.
authorJonathan Pryor <jonpryor@vt.edu>
Tue, 22 Nov 2011 15:58:49 +0000 (10:58 -0500)
committerJonathan Pryor <jonpryor@vt.edu>
Tue, 22 Nov 2011 17:25:58 +0000 (12:25 -0500)
Consider the intermix of a case-sensitive language (C#) and a
case-insensitive filesystem (OSX, Windows):

namespace A {
public class Foo {}
}
namespace a {
public class Bar {}
}

On a case-sensitive filesystem, this will generate the structure:

en/A/Foo.xml
en/a/Bar.xml

On a case-insensitive filesystem, we instead get:

en/A/Foo.xml
en/A/Bar.xml

The problem with this is that CleanupFiles() uses filenames to index
into the `goodfiles` HashSet<string>`, and the filenames will contain
e.g. "en/A/Bar.xml" for a.Bar, which won't exist in the HashSet, so it
thus thinks the type doesn't exist and removes the file.

This is obviously bad, but the fix is trivial: `goodfiles` should use
an OrdinalIgnoreCase string comparison, as this is what the filesystem
will be using on OS X and Windows.

mcs/tools/mdoc/Mono.Documentation/monodocer.cs

index dee1da2c0a4ea3106a80b3b2746f9b5451a755ae..224d8d0d7004ed7047ae30c380a1ac594619953b 100644 (file)
@@ -618,7 +618,7 @@ class MDocUpdater : MDocCommand
                index_assemblies.RemoveAll ();
 
 
-               HashSet<string> goodfiles = new HashSet<string> ();
+               HashSet<string> goodfiles = new HashSet<string> (StringComparer.OrdinalIgnoreCase);
 
                foreach (AssemblyDefinition assm in assemblies) {
                        AddIndexAssembly (assm, index_assemblies);