From 34272b313c0d11b532e9e545cd583835c57be712 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Tue, 1 Sep 2015 14:36:41 -0700 Subject: [PATCH] Initial commit --- .gitattributes | 50 +++++++++++++++++++++++ .gitignore | 36 +++++++++++++++++ NuGet.Config | 6 +++ WatchLots.sln | 33 ++++++++++++++++ global.json | 6 +++ src/WatchLots/Program.cs | 74 +++++++++++++++++++++++++++++++++++ src/WatchLots/WatchLots.xproj | 20 ++++++++++ src/WatchLots/project.json | 29 ++++++++++++++ 8 files changed, 254 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 NuGet.Config create mode 100644 WatchLots.sln create mode 100644 global.json create mode 100644 src/WatchLots/Program.cs create mode 100644 src/WatchLots/WatchLots.xproj create mode 100644 src/WatchLots/project.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdaa5ba --- /dev/null +++ b/.gitattributes @@ -0,0 +1,50 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.resx text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto +*.vbproj text=auto +*.fsproj text=auto +*.dbproj text=auto +*.sln text=auto eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a9bbc3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +*.sln.ide/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ +.vs/ +bower_components/ +node_modules/ +**/wwwroot/lib/ +debugSettings.json +project.lock.json +*.user +*.suo +*.cache +*.docstates +_ReSharper.* +nuget.exe +*net45.csproj +*net451.csproj +*k10.csproj +*.psess +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch +.settings +*.sln.ide +node_modules +**/[Cc]ompiler/[Rr]esources/**/*.js diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..26aec70 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/WatchLots.sln b/WatchLots.sln new file mode 100644 index 0000000..cb5bd2f --- /dev/null +++ b/WatchLots.sln @@ -0,0 +1,33 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B641BF61-0C5C-429F-ADC4-7EC52E57B205}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6262D40A-B965-4E55-BF40-C3CA8FE551DC}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + NuGet.Config = NuGet.Config + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WatchLots", "src\WatchLots\WatchLots.xproj", "{284454FE-ED93-4108-927D-01562B5CE3A7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {284454FE-ED93-4108-927D-01562B5CE3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {284454FE-ED93-4108-927D-01562B5CE3A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {284454FE-ED93-4108-927D-01562B5CE3A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {284454FE-ED93-4108-927D-01562B5CE3A7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {284454FE-ED93-4108-927D-01562B5CE3A7} = {B641BF61-0C5C-429F-ADC4-7EC52E57B205} + EndGlobalSection +EndGlobal diff --git a/global.json b/global.json new file mode 100644 index 0000000..cbd58bb --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "projects": [ "src", "test" ], + "sdk": { + "version": "default" + } +} diff --git a/src/WatchLots/Program.cs b/src/WatchLots/Program.cs new file mode 100644 index 0000000..09b4778 --- /dev/null +++ b/src/WatchLots/Program.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace WatchLots +{ + public class Program + { + public int Main(string[] args) + { + var watchers = new List(); + var current = Directory.GetCurrentDirectory(); + for (var i = 0; i < 25; i++) + { + for (var j = 0; j < 10; j++) + { + foreach (var file in Directory.EnumerateFiles(current, "project.json", SearchOption.AllDirectories)) + { + var directory = Path.GetDirectoryName(file); + var watcher = new FileSystemWatcher(directory) + { + IncludeSubdirectories = true, + }; + watcher.Changed += OnChanged; + watcher.Created += OnChanged; + watcher.Deleted += OnChanged; + watcher.Error += OnError; + watcher.Renamed += OnRenamed; + + try + { + watcher.EnableRaisingEvents = true; + } + catch (IOException exception) + { + Console.Error.WriteLine( + $"Caught Exception with HResult '{ exception.HResult }' after creating " + + $"{ watchers.Count } instances:" + + Environment.NewLine + + $"{ exception }"); + return 1; + } + + watchers.Add(watcher); + } + } + + Console.WriteLine($"Completed { 10 * (i + 1) } iterations."); + } + + return 0; + } + + private static void OnChanged(object sender, FileSystemEventArgs e) + { + Console.WriteLine($"File '{ e.FullPath }' had a '{ e.ChangeType }' change."); + } + + private static void OnError(object sender, ErrorEventArgs e) + { + var exception = e.GetException(); + Console.Error.WriteLine($"Hit an Exception with HResult '{ exception.HResult }'" + + Environment.NewLine + + $"{ exception }"); + + Environment.FailFast(exception.Message); + } + + private static void OnRenamed(object sender, RenamedEventArgs e) + { + Console.WriteLine($"File '{ e.OldFullPath }' renamed ('{ e.ChangeType }') to '{ e.FullPath }'."); + } + } +} diff --git a/src/WatchLots/WatchLots.xproj b/src/WatchLots/WatchLots.xproj new file mode 100644 index 0000000..c739462 --- /dev/null +++ b/src/WatchLots/WatchLots.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 284454fe-ed93-4108-927d-01562b5ce3a7 + WatchLots + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + diff --git a/src/WatchLots/project.json b/src/WatchLots/project.json new file mode 100644 index 0000000..0b05cc9 --- /dev/null +++ b/src/WatchLots/project.json @@ -0,0 +1,29 @@ +{ + "version": "1.0.0-*", + "description": "WatchLots Console Application", + "authors": [ "dougbu" ], + "tags": [ "" ], + "projectUrl": "", + "licenseUrl": "", + + "dependencies": { + }, + + "commands": { + "WatchLots": "WatchLots" + }, + + "frameworks": { + "dnx451": { }, + "dnxcore50": { + "dependencies": { + "System.Collections": "4.0.10-beta-*", + "System.Console": "4.0.0-beta-*", + "System.IO.FileSystem.Watcher": "4.0.0-beta-*", + "System.Linq": "4.0.0-beta-*", + "System.Threading": "4.0.10-beta-*", + "Microsoft.CSharp": "4.0.0-beta-*" + } + } + } +}