{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/comments/54184483","id":54184483,"diff_hunk":"@@ -0,0 +1,422 @@\n+﻿// Copyright (c) .NET Foundation. All rights reserved.\n+// Licensed under the MIT License. See License.txt in the project root for license information.\n+\n+using System;\n+using System.Collections.Generic;\n+using System.Collections.Immutable;\n+using System.Collections.ObjectModel;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Linq;\n+using System.Reflection;\n+using System.Text;\n+using System.Threading.Tasks;\n+using Microsoft.Azure.WebJobs.Host;\n+using Microsoft.Azure.WebJobs.Script.Binding;\n+using Microsoft.CodeAnalysis;\n+using Microsoft.CodeAnalysis.CSharp.Scripting;\n+using Microsoft.CodeAnalysis.Scripting;\n+\n+namespace Microsoft.Azure.WebJobs.Script.Description\n+{\n+    public class CSharpFunctionInvoker : ScriptFunctionInvokerBase\n+    {\n+        private const string ScriptClassName = \"Submission#0\";\n+\n+        private readonly ScriptHost _host;\n+        private readonly DictionaryJsonConverter _dictionaryJsonConverter = new DictionaryJsonConverter();\n+        private readonly TraceWriter _fileTraceWriter;\n+        private readonly FunctionMetadata _functionMetadata;\n+        private readonly BindingMetadata _trigger;\n+        private readonly Collection<FunctionBinding> _inputBindings;\n+        private readonly Collection<FunctionBinding> _outputBindings;\n+        private readonly FileSystemWatcher _fileWatcher;\n+        private readonly string _triggerParameterName;\n+        private readonly bool _omitInputParameter;\n+        private readonly IFunctionEntryPointResolver _functionEntryPointResolver;\n+        private MethodInfo _function;\n+        private FunctionMetadataResolver _metadataResolver;\n+        private readonly FunctionAssemblyLoader _assemblyLoader;\n+        private Action _reloadScript;\n+        private Action _restorePackages;\n+\n+        private static readonly string[] _watchedFileTypes = { \".cs\", \".csx\", \".dll\", \".exe\" };      \n+\n+        public CSharpFunctionInvoker(ScriptHost host, BindingMetadata trigger, FunctionMetadata metadata, bool omitInputParameter,\n+            Collection<FunctionBinding> inputBindings, Collection<FunctionBinding> outputBindings, \n+            IFunctionEntryPointResolver functionEntryPointResolver, FunctionAssemblyLoader assemblyLoader)\n+        {\n+            _host = host;\n+            _trigger = trigger;\n+            _triggerParameterName = trigger.Name;\n+            _omitInputParameter = omitInputParameter;\n+            _inputBindings = inputBindings;\n+            _outputBindings = outputBindings;\n+            _functionMetadata = metadata;\n+            _functionEntryPointResolver = functionEntryPointResolver;\n+            _fileWatcher = InitializeFileWatcher(host);\n+            _assemblyLoader = assemblyLoader;\n+\n+            if (_host.ScriptConfig.FileLoggingEnabled)\n+            {\n+                string logFilePath = Path.Combine(_host.ScriptConfig.RootLogPath, \"Function\", _functionMetadata.Name);\n+                _fileTraceWriter = new FileTraceWriter(logFilePath, TraceLevel.Verbose);\n+            }\n+            else\n+            {\n+                _fileTraceWriter = NullTraceWriter.Instance;\n+            }\n+\n+            _metadataResolver = new FunctionMetadataResolver(metadata, _fileTraceWriter);\n+\n+            _reloadScript = Debounce(ReloadScript);\n+            _restorePackages = Debounce(RestorePackages);\n+        }\n+\n+        private Action Debounce(Action targetAction, int milliseconds = 500)\n+        {\n+            Action<object> action = _ => targetAction();\n+            action = action.Debounce(500);\n+\n+            return () => action(null);\n+        }\n+\n+        private FileSystemWatcher InitializeFileWatcher(ScriptHost host)\n+        {\n+            FileSystemWatcher fileWatcher = null;\n+            if (host.ScriptConfig.FileWatchingEnabled)\n+            {\n+                string functionDirectory = Path.GetDirectoryName(_functionMetadata.Source);\n+                fileWatcher = new FileSystemWatcher(functionDirectory, \"*.*\")\n+                {\n+                    IncludeSubdirectories = true,\n+                    EnableRaisingEvents = true\n+                };\n+                fileWatcher.Changed += OnScriptFileChanged;\n+                fileWatcher.Created += OnScriptFileChanged;\n+                fileWatcher.Deleted += OnScriptFileChanged;\n+                fileWatcher.Renamed += OnScriptFileChanged;\n+            }\n+\n+            return fileWatcher;\n+        }\n+\n+        private void OnScriptFileChanged(object sender, FileSystemEventArgs e)\n+        {\n+            // The ScriptHost is already monitoring for changes to function.json, so we skip those\n+            string fileExtension = Path.GetExtension(e.Name);\n+            if (_watchedFileTypes.Contains(fileExtension))\n+            {\n+                _reloadScript();\n+            }\n+            else if (string.Compare(\"project.json\", e.Name, true) == 0)","path":"src/WebJobs.Script/Description/CSharp/CSharpFunctionInvoker.cs","position":112,"original_position":112,"commit_id":"a2791e8fdfaf0aea9fd67b70b471d8ce374e2d23","original_commit_id":"a2791e8fdfaf0aea9fd67b70b471d8ce374e2d23","user":{"login":"mathewc","id":1056548,"avatar_url":"https://avatars.githubusercontent.com/u/1056548?v=3","gravatar_id":"","url":"https://api.github.com/users/mathewc","html_url":"https://github.com/mathewc","followers_url":"https://api.github.com/users/mathewc/followers","following_url":"https://api.github.com/users/mathewc/following{/other_user}","gists_url":"https://api.github.com/users/mathewc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathewc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathewc/subscriptions","organizations_url":"https://api.github.com/users/mathewc/orgs","repos_url":"https://api.github.com/users/mathewc/repos","events_url":"https://api.github.com/users/mathewc/events{/privacy}","received_events_url":"https://api.github.com/users/mathewc/received_events","type":"User","site_admin":false},"body":"Might consider moving this as an internal constant, like ScriptHost.FunctionConfigFileName.","created_at":"2016-02-25T23:41:06Z","updated_at":"2016-02-25T23:41:06Z","html_url":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32#discussion_r54184483","pull_request_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/comments/54184483"},"html":{"href":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32#discussion_r54184483"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32","id":60735778,"html_url":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32","diff_url":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32.diff","patch_url":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32.patch","issue_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/32","number":32,"state":"open","locked":false,"title":"Adding C# language support","user":{"login":"fabiocav","id":2507935,"avatar_url":"https://avatars.githubusercontent.com/u/2507935?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiocav","html_url":"https://github.com/fabiocav","followers_url":"https://api.github.com/users/fabiocav/followers","following_url":"https://api.github.com/users/fabiocav/following{/other_user}","gists_url":"https://api.github.com/users/fabiocav/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiocav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiocav/subscriptions","organizations_url":"https://api.github.com/users/fabiocav/orgs","repos_url":"https://api.github.com/users/fabiocav/repos","events_url":"https://api.github.com/users/fabiocav/events{/privacy}","received_events_url":"https://api.github.com/users/fabiocav/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-25T19:46:14Z","updated_at":"2016-02-25T23:41:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd25f66462afb53c4d050e0993d44a7e4190f3f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/32/comments","statuses_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/statuses/a2791e8fdfaf0aea9fd67b70b471d8ce374e2d23","head":{"label":"fabiocav:csharp","ref":"csharp","sha":"a2791e8fdfaf0aea9fd67b70b471d8ce374e2d23","user":{"login":"fabiocav","id":2507935,"avatar_url":"https://avatars.githubusercontent.com/u/2507935?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiocav","html_url":"https://github.com/fabiocav","followers_url":"https://api.github.com/users/fabiocav/followers","following_url":"https://api.github.com/users/fabiocav/following{/other_user}","gists_url":"https://api.github.com/users/fabiocav/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiocav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiocav/subscriptions","organizations_url":"https://api.github.com/users/fabiocav/orgs","repos_url":"https://api.github.com/users/fabiocav/repos","events_url":"https://api.github.com/users/fabiocav/events{/privacy}","received_events_url":"https://api.github.com/users/fabiocav/received_events","type":"User","site_admin":false},"repo":{"id":51395540,"name":"azure-webjobs-sdk-script","full_name":"fabiocav/azure-webjobs-sdk-script","owner":{"login":"fabiocav","id":2507935,"avatar_url":"https://avatars.githubusercontent.com/u/2507935?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiocav","html_url":"https://github.com/fabiocav","followers_url":"https://api.github.com/users/fabiocav/followers","following_url":"https://api.github.com/users/fabiocav/following{/other_user}","gists_url":"https://api.github.com/users/fabiocav/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiocav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiocav/subscriptions","organizations_url":"https://api.github.com/users/fabiocav/orgs","repos_url":"https://api.github.com/users/fabiocav/repos","events_url":"https://api.github.com/users/fabiocav/events{/privacy}","received_events_url":"https://api.github.com/users/fabiocav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabiocav/azure-webjobs-sdk-script","description":"Scripting the Azure WebJobs SDK","fork":true,"url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script","forks_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/forks","keys_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/teams","hooks_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/hooks","issue_events_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/issues/events{/number}","events_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/events","assignees_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/assignees{/user}","branches_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/branches{/branch}","tags_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/tags","blobs_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/statuses/{sha}","languages_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/languages","stargazers_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/stargazers","contributors_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/contributors","subscribers_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/subscribers","subscription_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/subscription","commits_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/contents/{+path}","compare_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/merges","archive_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/downloads","issues_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/issues{/number}","pulls_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/pulls{/number}","milestones_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/milestones{/number}","notifications_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/labels{/name}","releases_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/releases{/id}","deployments_url":"https://api.github.com/repos/fabiocav/azure-webjobs-sdk-script/deployments","created_at":"2016-02-09T20:00:09Z","updated_at":"2016-02-09T20:00:10Z","pushed_at":"2016-02-25T05:45:56Z","git_url":"git://github.com/fabiocav/azure-webjobs-sdk-script.git","ssh_url":"git@github.com:fabiocav/azure-webjobs-sdk-script.git","clone_url":"https://github.com/fabiocav/azure-webjobs-sdk-script.git","svn_url":"https://github.com/fabiocav/azure-webjobs-sdk-script","homepage":"","size":14008,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"5a044fa13ea557360e13c3436b6257627cee653a","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":42548553,"name":"azure-webjobs-sdk-script","full_name":"Azure/azure-webjobs-sdk-script","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars.githubusercontent.com/u/6844498?v=3","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-webjobs-sdk-script","description":"Scripting the Azure WebJobs SDK","fork":false,"url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script","forks_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/forks","keys_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/teams","hooks_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/events","assignees_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/tags","blobs_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/subscription","commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/merges","archive_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/downloads","issues_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/deployments","created_at":"2015-09-15T21:48:19Z","updated_at":"2016-02-17T20:06:22Z","pushed_at":"2016-02-25T23:23:33Z","git_url":"git://github.com/Azure/azure-webjobs-sdk-script.git","ssh_url":"git@github.com:Azure/azure-webjobs-sdk-script.git","clone_url":"https://github.com/Azure/azure-webjobs-sdk-script.git","svn_url":"https://github.com/Azure/azure-webjobs-sdk-script","homepage":"","size":14065,"stargazers_count":16,"watchers_count":16,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":18,"forks":6,"open_issues":18,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32"},"html":{"href":"https://github.com/Azure/azure-webjobs-sdk-script/pull/32"},"issue":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/32"},"comments":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/issues/32/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/pulls/32/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-webjobs-sdk-script/statuses/a2791e8fdfaf0aea9fd67b70b471d8ce374e2d23"}}}}