{"action":"created","issue":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/418","labels_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/418/labels{/name}","comments_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/418/comments","events_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/418/events","html_url":"https://github.com/AutoFixture/AutoFixture/pull/418","id":89477004,"number":418,"title":"Extract common GetData logic from framework-specific AutoDataAttribute classes","user":{"login":"olegsych","id":8355091,"avatar_url":"https://avatars.githubusercontent.com/u/8355091?v=3","gravatar_id":"","url":"https://api.github.com/users/olegsych","html_url":"https://github.com/olegsych","followers_url":"https://api.github.com/users/olegsych/followers","following_url":"https://api.github.com/users/olegsych/following{/other_user}","gists_url":"https://api.github.com/users/olegsych/gists{/gist_id}","starred_url":"https://api.github.com/users/olegsych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegsych/subscriptions","organizations_url":"https://api.github.com/users/olegsych/orgs","repos_url":"https://api.github.com/users/olegsych/repos","events_url":"https://api.github.com/users/olegsych/events{/privacy}","received_events_url":"https://api.github.com/users/olegsych/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-19T06:01:23Z","updated_at":"2015-09-05T16:34:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/pulls/418","html_url":"https://github.com/AutoFixture/AutoFixture/pull/418","diff_url":"https://github.com/AutoFixture/AutoFixture/pull/418.diff","patch_url":"https://github.com/AutoFixture/AutoFixture/pull/418.patch"},"body":"This pull request is a first step in implementing fixture customization attributes discussed in #132. \r\n\r\nDefining attributes that are specific to a _mocking_ framework without taking a dependency on a specific _test_ framework is not possible today because the `CustomizeAttribute` classes are defined in the _test framework assemblies_, like `AutoFixture.Nunit2` and `AutoFixture.Xunit2`. To solve this problem, this pull request introduces a new Kernel interface, `IParameterCustomizationProvider` that can be implemented by attributes defined by any of the \"mocking\" assemblies, like `AutoFixture.NSubstitute`, without additional dependencies. The existing `CustomizeAttribute` classes will implement this new interface to maintain backward compatibility for current users of v3.\r\n\r\nHere is an example of a hypothetical customization attribute this pull request will allow to create in `AutoFixture.NSubstitute`. This attribute will be automatically supported by all three test frameworks supported by AutoFixture today - `AutoFixture.NUnit2`, `AutoFixture.xUnit.net` and `AutoFixture.xUnit.net2` without code duplication or additional dependencies.\r\n\r\n```C#\r\nnamespace AutoFixture.NSubstitute\r\n{\r\n    [AttributeUsage(AttributeTargets.Parameter)]    \r\n    public class SubstituteAttribute : Attribute, IParameterCustomizatoinProvider\r\n    {\r\n        public ICustomization GetCustomization(ParameterInfo parameter)\r\n        {\r\n            return new SubstituteConcreteTypeCustomization(parameter);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nHere is the potential usage of the hypothetical attribute in customer code.\r\n\r\n``` C#\r\nusing AutoFixture.NSubstitute;\r\nusing Xunit;\r\n\r\npublic class MyTest\r\n{\r\n    [Fact, DefaultNSubstituteConventions]\r\n    public void Test1([Substitute]ConcreteType sample)\r\n    {\r\n        // Fixture setup\r\n        // Exercise system\r\n        sample.HelloWorld();\r\n        // Verify results\r\n        sample.Received().HelloWorld();\r\n        // Teardown\r\n    }\r\n}\r\n```\r\n\r\nThis pull request also introduces a new utility class, `TestDataProvider` along with the matching `ITestDataProvider` interface. It consolidates the logic common to all `GetData` implementations in test framework-specific `AutoDataAttribute` classes and adds support for the new `IParameterCustomizationProvider` interface.The `AutoDataAttribute` classes use the new utility class instead of maintaining duplicate implementations of the common logic. \r\n\r\n## Changes\r\n- [x] Intruduce Kernel abstractions and default implementation\r\n- [x] Update `AutoDataAttribute` and `CustomizeAttribute` for xUnit.net\r\n- [x] Update `AutoDataAttribute` and `CustomizeAttribute` for xUnit.net2\r\n- [X] Update `AutoDataAttribute` and `CustomizeAttribute` for Nunit2\r\n"},"comment":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/comments/137972935","html_url":"https://github.com/AutoFixture/AutoFixture/pull/418#issuecomment-137972935","issue_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/418","id":137972935,"user":{"login":"olegsych","id":8355091,"avatar_url":"https://avatars.githubusercontent.com/u/8355091?v=3","gravatar_id":"","url":"https://api.github.com/users/olegsych","html_url":"https://github.com/olegsych","followers_url":"https://api.github.com/users/olegsych/followers","following_url":"https://api.github.com/users/olegsych/following{/other_user}","gists_url":"https://api.github.com/users/olegsych/gists{/gist_id}","starred_url":"https://api.github.com/users/olegsych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olegsych/subscriptions","organizations_url":"https://api.github.com/users/olegsych/orgs","repos_url":"https://api.github.com/users/olegsych/repos","events_url":"https://api.github.com/users/olegsych/events{/privacy}","received_events_url":"https://api.github.com/users/olegsych/received_events","type":"User","site_admin":false},"created_at":"2015-09-05T16:34:04Z","updated_at":"2015-09-05T16:34:04Z","body":"Now that the `SubstituteAttribute` is implemented, I'd like to continue working on this pull request because it provides the foundation required to prevent the obscure test failures due to missing NSubstitute customization described in #430."}}