4 changed files with 178 additions and 9 deletions
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("ICSharpCode.NRefactory.CSharp.AstVerifier")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("mike")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProductVersion>10.0.0</ProductVersion> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>{961DADFA-7CE6-429F-BC22-47630D6DB826}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<RootNamespace>ICSharpCode.NRefactory.CSharp.AstVerifier</RootNamespace> |
||||
<AssemblyName>AstVerifier</AssemblyName> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Debug</OutputPath> |
||||
<DefineConstants>DEBUG;</DefineConstants> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>none</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<OutputPath>bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<Externalconsole>true</Externalconsole> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Main.cs" /> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj"> |
||||
<Project>{53DCA265-3C3C-42F9-B647-F72BA678122B}</Project> |
||||
<Name>ICSharpCode.NRefactory.CSharp</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj"> |
||||
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project> |
||||
<Name>ICSharpCode.NRefactory</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
</Project> |
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
using System; |
||||
using System.IO; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp.AstVerifier |
||||
{ |
||||
class MainClass |
||||
{ |
||||
static bool IsMatch (string src1, string src2, out int i, out int j) |
||||
{ |
||||
i = 0; |
||||
j = 0; |
||||
while (i < src1.Length && j < src2.Length) { |
||||
char c1 = src1 [i]; |
||||
char c2 = src2 [j]; |
||||
if (char.IsWhiteSpace (c1)) { |
||||
i++; |
||||
continue; |
||||
} |
||||
if (char.IsWhiteSpace (c2)) { |
||||
j++; |
||||
continue; |
||||
} |
||||
if (c1 != c2) { |
||||
Console.WriteLine ( i + ":"+ c1 + "!= " +j +":" + c2); |
||||
return false; |
||||
} |
||||
i++; |
||||
j++; |
||||
} |
||||
while (i < src1.Length && char.IsWhiteSpace (src1[i])) { |
||||
i++; |
||||
} |
||||
while (j < src2.Length && char.IsWhiteSpace (src2[j])) { |
||||
j++; |
||||
} |
||||
|
||||
return i == src1.Length && j == src2.Length; |
||||
} |
||||
|
||||
public static void Main (string[] args) |
||||
{ |
||||
if (args.Length == 0) { |
||||
Console.WriteLine ("Usage: AstVerifier [Directory]"); |
||||
return; |
||||
} |
||||
try { |
||||
if (!Directory.Exists (args[0])) { |
||||
Console.WriteLine ("Directory not found."); |
||||
return; |
||||
} |
||||
} catch (IOException) { |
||||
Console.WriteLine ("Exception while trying to access the directory."); |
||||
return; |
||||
} |
||||
int failed = 0, passed = 0; |
||||
Console.WriteLine ("search in " + args [0]); |
||||
foreach (var file in Directory.GetFileSystemEntries (args[0], "*", SearchOption.AllDirectories)) { |
||||
if (!file.EndsWith (".cs")) |
||||
continue; |
||||
string text = File.ReadAllText (file); |
||||
var unit = CompilationUnit.Parse (text, file); |
||||
if (unit == null) |
||||
continue; |
||||
string generated = unit.GetText (); |
||||
int i, j; |
||||
if (!IsMatch (text, generated, out i, out j)) { |
||||
if (i > 0 && j > 0) { |
||||
Console.WriteLine ("fail :" + file + "----original:"); |
||||
Console.WriteLine (text.Substring (0, i + 1)); |
||||
Console.WriteLine ("----generated:"); |
||||
Console.WriteLine (generated.Substring (0, j + 1)); |
||||
} |
||||
failed++; |
||||
} else { |
||||
passed++; |
||||
} |
||||
} |
||||
|
||||
Console.WriteLine ("{0} passed, {1} failed", passed, failed); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue