{"action":"created","issue":{"url":"https://api.github.com/repos/code-cracker/code-cracker/issues/822","repository_url":"https://api.github.com/repos/code-cracker/code-cracker","labels_url":"https://api.github.com/repos/code-cracker/code-cracker/issues/822/labels{/name}","comments_url":"https://api.github.com/repos/code-cracker/code-cracker/issues/822/comments","events_url":"https://api.github.com/repos/code-cracker/code-cracker/issues/822/events","html_url":"https://github.com/code-cracker/code-cracker/issues/822","id":171400391,"number":822,"title":"Bug: \"UseStaticRegexIsMatchAnalyzer\" causes an exception (CC0081)","user":{"login":"ElStefan","id":18227130,"avatar_url":"https://avatars.githubusercontent.com/u/18227130?v=3","gravatar_id":"","url":"https://api.github.com/users/ElStefan","html_url":"https://github.com/ElStefan","followers_url":"https://api.github.com/users/ElStefan/followers","following_url":"https://api.github.com/users/ElStefan/following{/other_user}","gists_url":"https://api.github.com/users/ElStefan/gists{/gist_id}","starred_url":"https://api.github.com/users/ElStefan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElStefan/subscriptions","organizations_url":"https://api.github.com/users/ElStefan/orgs","repos_url":"https://api.github.com/users/ElStefan/repos","events_url":"https://api.github.com/users/ElStefan/events{/privacy}","received_events_url":"https://api.github.com/users/ElStefan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/code-cracker/code-cracker/labels/3%20-%20Done","name":"3 - Done","color":"CCCCCC"},{"url":"https://api.github.com/repos/code-cracker/code-cracker/labels/analyzer","name":"analyzer","color":"0052cc"},{"url":"https://api.github.com/repos/code-cracker/code-cracker/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/code-cracker/code-cracker/labels/C%23","name":"C#","color":"5319e7"}],"state":"closed","locked":false,"assignee":{"login":"carloscds","id":1697221,"avatar_url":"https://avatars.githubusercontent.com/u/1697221?v=3","gravatar_id":"","url":"https://api.github.com/users/carloscds","html_url":"https://github.com/carloscds","followers_url":"https://api.github.com/users/carloscds/followers","following_url":"https://api.github.com/users/carloscds/following{/other_user}","gists_url":"https://api.github.com/users/carloscds/gists{/gist_id}","starred_url":"https://api.github.com/users/carloscds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carloscds/subscriptions","organizations_url":"https://api.github.com/users/carloscds/orgs","repos_url":"https://api.github.com/users/carloscds/repos","events_url":"https://api.github.com/users/carloscds/events{/privacy}","received_events_url":"https://api.github.com/users/carloscds/received_events","type":"User","site_admin":false},"assignees":[{"login":"carloscds","id":1697221,"avatar_url":"https://avatars.githubusercontent.com/u/1697221?v=3","gravatar_id":"","url":"https://api.github.com/users/carloscds","html_url":"https://github.com/carloscds","followers_url":"https://api.github.com/users/carloscds/followers","following_url":"https://api.github.com/users/carloscds/following{/other_user}","gists_url":"https://api.github.com/users/carloscds/gists{/gist_id}","starred_url":"https://api.github.com/users/carloscds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carloscds/subscriptions","organizations_url":"https://api.github.com/users/carloscds/orgs","repos_url":"https://api.github.com/users/carloscds/repos","events_url":"https://api.github.com/users/carloscds/events{/privacy}","received_events_url":"https://api.github.com/users/carloscds/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/code-cracker/code-cracker/milestones/16","html_url":"https://github.com/code-cracker/code-cracker/milestones/1.0.1","labels_url":"https://api.github.com/repos/code-cracker/code-cracker/milestones/16/labels","id":1711860,"number":16,"title":"1.0.1","description":"","creator":{"login":"giggio","id":334958,"avatar_url":"https://avatars.githubusercontent.com/u/334958?v=3","gravatar_id":"","url":"https://api.github.com/users/giggio","html_url":"https://github.com/giggio","followers_url":"https://api.github.com/users/giggio/followers","following_url":"https://api.github.com/users/giggio/following{/other_user}","gists_url":"https://api.github.com/users/giggio/gists{/gist_id}","starred_url":"https://api.github.com/users/giggio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giggio/subscriptions","organizations_url":"https://api.github.com/users/giggio/orgs","repos_url":"https://api.github.com/users/giggio/repos","events_url":"https://api.github.com/users/giggio/events{/privacy}","received_events_url":"https://api.github.com/users/giggio/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":13,"state":"open","created_at":"2016-04-17T04:05:44Z","updated_at":"2016-08-26T23:39:17Z","due_on":"2016-08-28T00:00:00Z","closed_at":null},"comments":5,"created_at":"2016-08-16T12:51:27Z","updated_at":"2016-08-26T23:39:17Z","closed_at":"2016-08-26T23:39:17Z","body":"Hi,\r\n\r\nwhile working with regular expressions in C#, an exception occured in the error list caused by code-cracker.\r\n\r\nAfter some playing around with the code, i found the suspicous part in my code which is causing the exception.\r\n\r\n````csharp\r\npublic class RegexTestClass\r\n{\r\n    private TestModel testModel;\r\n\r\n    private void Test(string text)\r\n    {\r\n        if (testModel.Regex.IsMatch(text))\r\n        {\r\n            return;\r\n        }\r\n    }\r\n}\r\n\r\npublic class TestModel\r\n{\r\n    public System.Text.RegularExpressions.Regex Regex { get; set; }\r\n}\r\n````\r\n\r\nThe exception (only got it in german):\r\n\r\n````\r\nAnalyzer 'CodeCracker.CSharp.Performance.UseStaticRegexIsMatchAnalyzer' threw \r\nan exception of type 'System.InvalidCastException' with message\r\n'Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax'.'.\t\r\n````\r\n\r\nA more complex scenario:\r\n\r\n````csharp\r\npublic class RegexTestClass\r\n{\r\n    private C c;\r\n\r\n    private void Test(string text)\r\n    {\r\n        if (c.TestModel.Regex.IsMatch(text))\r\n        {\r\n            return;\r\n        }\r\n    }\r\n}\r\npublic class C\r\n{\r\n    public TestModel TestModel { get; set; }\r\n}\r\npublic class TestModel\r\n{\r\n    public System.Text.RegularExpressions.Regex Regex { get; set; }\r\n}\r\n````\r\n\r\n````\r\nActive\tAnalyzer 'CodeCracker.CSharp.Performance.UseStaticRegexIsMatchAnalyzer' threw the following exception:\r\n'Exception occurred with following context:\r\nCompilation: ConsoleApplication1\r\nSyntaxTree: c:\\temp\\ConsoleApplication1\\ConsoleApplication1\\Program.cs\r\nSyntaxNode: testModel.Regex.IsMatch(text) [InvocationExpressionSyntax]@[439..468) (21,16)-(21,45)\r\n\r\nSystem.InvalidCastException: Unable to cast object of type 'Microsoft.CodeAnalysis.CSharp.Syntax.MemberAccessExpressionSyntax' to type 'Microsoft.CodeAnalysis.CSharp.Syntax.IdentifierNameSyntax'.\r\n   at CodeCracker.CSharp.Performance.UseStaticRegexIsMatchAnalyzer.Analyzer(SyntaxNodeAnalysisContext context) in C:\\p\\code-cracker\\src\\CSharp\\CodeCracker\\Performance\\UseStaticRegexIsMatchAnalyzer.cs:line 44\r\n   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass42_1`1.<ExecuteSyntaxNodeAction>b__1()\r\n   at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info)\r\n````\r\n\r\nI guess the problematic line is in [here](https://github.com/code-cracker/code-cracker/blob/master/src/CSharp/CodeCracker/Performance/UseStaticRegexIsMatchAnalyzer.cs) on line 44\r\n\r\nThanks, and thanks again for fixing the other issue I submitted!\r\n\r\nThe PR has to go on the `v1.0.x` branch."},"comment":{"url":"https://api.github.com/repos/code-cracker/code-cracker/issues/comments/242876981","html_url":"https://github.com/code-cracker/code-cracker/issues/822#issuecomment-242876981","issue_url":"https://api.github.com/repos/code-cracker/code-cracker/issues/822","id":242876981,"user":{"login":"giggio","id":334958,"avatar_url":"https://avatars.githubusercontent.com/u/334958?v=3","gravatar_id":"","url":"https://api.github.com/users/giggio","html_url":"https://github.com/giggio","followers_url":"https://api.github.com/users/giggio/followers","following_url":"https://api.github.com/users/giggio/following{/other_user}","gists_url":"https://api.github.com/users/giggio/gists{/gist_id}","starred_url":"https://api.github.com/users/giggio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giggio/subscriptions","organizations_url":"https://api.github.com/users/giggio/orgs","repos_url":"https://api.github.com/users/giggio/repos","events_url":"https://api.github.com/users/giggio/events{/privacy}","received_events_url":"https://api.github.com/users/giggio/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T23:39:17Z","updated_at":"2016-08-26T23:39:17Z","body":"Closed on #833"}}
{"actor":{"display_login":"giggio"}}