{"action":"created","issue":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/317","labels_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/317/labels{/name}","comments_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/317/comments","events_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/317/events","html_url":"https://github.com/AutoFixture/AutoFixture/pull/317","id":45919569,"number":317,"title":"Freeze on match customization","user":{"login":"ecampidoglio","id":877348,"avatar_url":"https://avatars.githubusercontent.com/u/877348?v=3","gravatar_id":"","url":"https://api.github.com/users/ecampidoglio","html_url":"https://github.com/ecampidoglio","followers_url":"https://api.github.com/users/ecampidoglio/followers","following_url":"https://api.github.com/users/ecampidoglio/following{/other_user}","gists_url":"https://api.github.com/users/ecampidoglio/gists{/gist_id}","starred_url":"https://api.github.com/users/ecampidoglio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ecampidoglio/subscriptions","organizations_url":"https://api.github.com/users/ecampidoglio/orgs","repos_url":"https://api.github.com/users/ecampidoglio/repos","events_url":"https://api.github.com/users/ecampidoglio/events{/privacy}","received_events_url":"https://api.github.com/users/ecampidoglio/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-10-15T21:04:41Z","updated_at":"2015-01-27T13:08:52Z","closed_at":"2015-01-27T12:37:14Z","pull_request":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/pulls/317","html_url":"https://github.com/AutoFixture/AutoFixture/pull/317","diff_url":"https://github.com/AutoFixture/AutoFixture/pull/317.diff","patch_url":"https://github.com/AutoFixture/AutoFixture/pull/317.patch"},"body":"Addresses #120 by introducing a new customization that freezes specimens based on a set of criteria.\r\n\r\n### Usage\r\n\r\nThe `FreezeOnMatchCustomization` uses the `IRequestSpecification` abstraction as a way to match the incoming requests with the frozen specimen. For example:\r\n\r\n```csharp\r\nvar fixture = new Fixture();\r\nvar freeze = new FreezeOnMatchCustomization(\r\n    typeof(string),\r\n    new PropertySpecification(typeof(string), \"Foo\"));\r\nfixture.Customize(freeze);\r\n```\r\n\r\nThis will assign the same string value to _all properties of type `string` named `\"Foo\"`_.\r\n\r\nMultiple matching criteria can also be combined using the `OrRequestSpecification`. Here's an example:\r\n\r\n```csharp\r\nvar fixture = new Fixture();\r\nvar freeze = new FreezeOnMatchCustomization(\r\n    typeof(string),\r\n    new OrRequestSpecification(\r\n        new PropertySpecification(typeof(string), \"Foo\")\r\n        new ParameterSpecification(typeof(string), \"bar\"))); \r\nfixture.Customize(freeze);\r\n```\r\n\r\nWhen no matching criteria are specified, the `FreezeOnMatchCustomization` behaves like the current `FreezingCustomization`, that is it will only match by _exact type_. More concretely:\r\n\r\n```csharp\r\nvar freeze = new FreezeOnMatchCustomization(typeof(string));\r\n```\r\n\r\nis the same as saying:\r\n\r\n```csharp\r\nvar freeze = new FreezeOnMatchCustomization(typeof(string), new ExactTypeSpecification(typeof(string));\r\n```\r\n\r\n### Follow-ups\r\n\r\nThe are a few things I deliberately left out until after I gather your feedback:\r\n\r\n- Since the `FreezeOnMatchCustomization` effectively supersedes the existing `FreezingCustomization`, I propose we obsolete it and rename the `FreezeOnMatchCustomization` to simply be `FreezeCustomization` for consistency.\r\n- I'll add the XML documentation once the feature is finalized.\r\n\r\nI look forward to your comments."},"comment":{"url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/comments/71644860","html_url":"https://github.com/AutoFixture/AutoFixture/pull/317#issuecomment-71644860","issue_url":"https://api.github.com/repos/AutoFixture/AutoFixture/issues/317","id":71644860,"user":{"login":"ploeh","id":242165,"avatar_url":"https://avatars.githubusercontent.com/u/242165?v=3","gravatar_id":"","url":"https://api.github.com/users/ploeh","html_url":"https://github.com/ploeh","followers_url":"https://api.github.com/users/ploeh/followers","following_url":"https://api.github.com/users/ploeh/following{/other_user}","gists_url":"https://api.github.com/users/ploeh/gists{/gist_id}","starred_url":"https://api.github.com/users/ploeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ploeh/subscriptions","organizations_url":"https://api.github.com/users/ploeh/orgs","repos_url":"https://api.github.com/users/ploeh/repos","events_url":"https://api.github.com/users/ploeh/events{/privacy}","received_events_url":"https://api.github.com/users/ploeh/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T13:08:52Z","updated_at":"2015-01-27T13:08:52Z","body":"Thank you for your contribution! It's now live as [AutoFixture 3.23.0](http://www.nuget.org/packages/AutoFixture/3.23.0). "}}