{"action":"created","issue":{"url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/20","repository_url":"https://api.github.com/repos/DonZoeggerle/ediFabric","labels_url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/20/comments","events_url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/20/events","html_url":"https://github.com/DonZoeggerle/ediFabric/issues/20","id":132172167,"number":20,"title":"Expects wrong namespace for custom-generated classes","user":{"login":"zaus","id":784367,"avatar_url":"https://avatars.githubusercontent.com/u/784367?v=3","gravatar_id":"","url":"https://api.github.com/users/zaus","html_url":"https://github.com/zaus","followers_url":"https://api.github.com/users/zaus/followers","following_url":"https://api.github.com/users/zaus/following{/other_user}","gists_url":"https://api.github.com/users/zaus/gists{/gist_id}","starred_url":"https://api.github.com/users/zaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaus/subscriptions","organizations_url":"https://api.github.com/users/zaus/orgs","repos_url":"https://api.github.com/users/zaus/repos","events_url":"https://api.github.com/users/zaus/events{/privacy}","received_events_url":"https://api.github.com/users/zaus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-08T15:27:35Z","updated_at":"2016-02-08T15:54:16Z","closed_at":null,"body":"I downloaded the [002040 X12 samples](http://edifabric.com/edifabricweb/00204.zip) from http://edifabric.com/x12/ and generated the classes. _(aside: why not just provide the `.cs` files directly?)_\r\n\r\nIt created the classes under namespace `EdiFabric.Definitions.X12_002040_850` (note the **002040** matching the download set name).\r\n\r\nFollowing the guide instructions on http://edifabric.com/guide/, I added those files directly to my solution in a new project \"Definitions\".\r\nIn another project using the `ediFabric` NuGet package I basically copied the `Load` helper from the SDK project https://github.com/DonZoeggerle/ediFabric.Sdk.EdiToObject, the relevant line being:\r\n\r\n\t// Parse the EDI\r\n\t// Pass in the name of the assembly because the class is not in the default assembly (configured in app.config or EdiFabric.Definitions)\r\n\tinterchange = Interchange.LoadFrom(source, \"Definitions\");\r\n\t... later\r\n\tyield return msg.DeserializeItem<T>(); // where T is supposed to be one of the autogenerated message classes\r\n\r\nA unit test in another project of the same solution, referencing both projects, failed with the following exception:\r\n\r\n> Test method Edi.Tests.EdiConversionTests.Edi_Load threw exception: \r\nSystem.Exception: Failed to load edi source stream ---> EdiFabric.Framework.ParserException: Can't find type for type name = EdiFabric.Definitions.X12_004010_850.M_850, Definitions\r\n\r\nI was wracking my brains trying figure out why it couldn't find the type (had I not named the assemblies correctly?  included them properly) when I noticed the namespace it's looking for (note the **004010** which is from another download set?) didn't match the class I had included and referenced.\r\n\r\nAfter going in to the autogenerated class and replacing `002040` with `004010` it loads correctly.\r\n"},"comment":{"url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/comments/181437379","html_url":"https://github.com/DonZoeggerle/ediFabric/issues/20#issuecomment-181437379","issue_url":"https://api.github.com/repos/DonZoeggerle/ediFabric/issues/20","id":181437379,"user":{"login":"zaus","id":784367,"avatar_url":"https://avatars.githubusercontent.com/u/784367?v=3","gravatar_id":"","url":"https://api.github.com/users/zaus","html_url":"https://github.com/zaus","followers_url":"https://api.github.com/users/zaus/followers","following_url":"https://api.github.com/users/zaus/following{/other_user}","gists_url":"https://api.github.com/users/zaus/gists{/gist_id}","starred_url":"https://api.github.com/users/zaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaus/subscriptions","organizations_url":"https://api.github.com/users/zaus/orgs","repos_url":"https://api.github.com/users/zaus/repos","events_url":"https://api.github.com/users/zaus/events{/privacy}","received_events_url":"https://api.github.com/users/zaus/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T15:54:16Z","updated_at":"2016-02-08T15:54:16Z","body":"It might also help to offer a generic-type overload that automatically gets the definition assembly name from the provided type, like:\r\n\r\n\tpublic Interchange LoadFrom<T>(Stream source) {\r\n\t\tvar type = typeof(T);\r\n\t\t// would have liked to just pass `type.AssemblyQualifiedName`\r\n\r\n\t\tvar actualAssembly = type.GetAssembly().Name;\r\n\t\tvar fabricExpectedAssemblyName = actualAssembly.Substring(0, actualAssembly.IndexOf(\", Version\"));\r\n\t\treturn Interchange.LoadFrom(source, fabricExpectedAssemblyName);\r\n\t}"}}