├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md └── Source └── DesignTimeMapper ├── DesignTimeMapper.CommandLine ├── App.config ├── DesignTimeMapper.CommandLine.csproj ├── DesignTimeMapper.targets ├── FodyWeavers.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── DesignTimeMapper.Engine ├── App.config ├── DesignTimeMapper.Engine.csproj ├── Extensions │ ├── RoslynExtensions.cs │ └── StringExtensions.cs ├── Interface │ └── IMapperMethodGenerator.cs ├── MapperGeneration │ ├── ClassMapper.cs │ ├── Mapper.cs │ └── MapperMethodGenerator.cs ├── Model │ ├── MapTreeNode.cs │ └── MatchingPropertyTree.cs ├── Properties │ └── AssemblyInfo.cs ├── Settings │ └── DtmSettings.cs └── packages.config ├── DesignTimeMapper.ExamplePocos ├── AddressDto.cs ├── ClassWithExternalReference.cs ├── DesignTimeMapper.ExamplePocos.csproj ├── DtmExtensions.cs ├── NestedClass.cs ├── NestedClassDto.cs ├── Properties │ └── AssemblyInfo.cs ├── SimpleClass.cs ├── app.config └── packages.config ├── DesignTimeMapper.Tests ├── DesignTimeMapper.Tests.csproj ├── Integration │ ├── MapperMethodGeneratorIntegrationTests.cs │ └── SimpleClassIntegrationTests.cs ├── Properties │ └── AssemblyInfo.cs ├── Unit │ └── MapperMethodGeneratorTests.cs ├── app.config └── packages.config ├── DesignTimeMapper.sln └── DesignTimeMapper ├── Attributes ├── DoNotMapAttribute.cs └── MapFromAttribute.cs ├── DesignTimeMapper.csproj ├── DesignTimeMapper.nuspec ├── Properties └── AssemblyInfo.cs └── build └── DesignTimeMapper.targets /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | /Source/DesignTimeMapper/DesignTimeMapper/tools/DesignTimeMapper.CommandLine.exe 254 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: DesignTimeMapper/DesignTimeMapper.sln -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Alistair Clark 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DesignTimeMapper 2 | NuGet package for creating object-object mapping methods. 3 | 4 | ## How to install ## 5 | 6 | Install from NuGet. Use the command `Install-Package DesignTimeMapper` 7 | 8 | ## What is it? ## 9 | 10 | It's like AutoMapper. But instead of the mappings happening at run time, they are created at compile time using Roslyn to generate extension methods. 11 | 12 | ## How to use ## 13 | 14 | Add the `MapFromAttribute` to a class with the type you want to map from. 15 | E.g. given these classes 16 | 17 | public class ClassWithNesting 18 | { 19 | public string Property1 { get; set; } 20 | public SimpleClass Nested { get; set; } 21 | } 22 | 23 | public class SimpleClass 24 | { 25 | public int Property1 { get; set; } 26 | public string Property2 { get; set; } 27 | } 28 | 29 | [MapFrom(typeof(ClassWithNesting))] 30 | public class ClassWithNestingDto 31 | { 32 | public string Property1 { get; set; } 33 | public int NestedProperty1 { get; set; } 34 | public string NestedProperty2 { get; set; } 35 | } 36 | 37 | The result of the mapping will be 38 | 39 | public static DesignTimeMapper.ExamplePocos.ClassWithNestingDto MapToNestedClassDto(this ClassWithNesting nestedclass) 40 | { 41 | return new DesignTimeMapper.ExamplePocos.ClassWithNestingDto() 42 | {Property1 = nestedclass.Property1, NestedProperty1 = nestedclass.Nested.Property1, NestedProperty2 = nestedclass.Nested.Property2}; 43 | } 44 | 45 | public static ClassWithNesting MapToNestedClass(this DesignTimeMapper.ExamplePocos.ClassWithNestingDto nestedclass) 46 | { 47 | return new ClassWithNesting() 48 | {Property1 = nestedclass.Property1, Nested = new DesignTimeMapper.ExamplePocos.SimpleClass() 49 | {Property1 = nestedclass.NestedProperty1, Property2 = nestedclass.NestedProperty2}}; 50 | } 51 | 52 | If you want to exclude properties from being mapped then use the `DoNotMapAttribute` 53 | 54 | E.g. 55 | 56 | [MapFrom(typeof(ClassWithNesting))] 57 | public class ClassWithNestingDto 58 | { 59 | [DoNotMap] 60 | public string Property1 { get; set; } 61 | public int NestedProperty1 { get; set; } 62 | public string NestedProperty2 { get; set; } 63 | } 64 | 65 | Will result in a mapping of 66 | 67 | public static DesignTimeMapper.ExamplePocos.ClassWithNestingDto MapToClassWithNestingDto(this ClassWithNesting classwithnesting) 68 | { 69 | return new DesignTimeMapper.ExamplePocos.ClassWithNestingDto() 70 | {NestedProperty1 = classwithnesting.Nested.Property1, NestedProperty2 = classwithnesting.Nested.Property2}; 71 | } 72 | 73 | public static ClassWithNesting MapToClassWithNesting(this DesignTimeMapper.ExamplePocos.ClassWithNestingDto classwithnesting) 74 | { 75 | return new ClassWithNesting() 76 | {Nested = new DesignTimeMapper.ExamplePocos.SimpleClass() 77 | {Property1 = classwithnesting.NestedProperty1, Property2 = classwithnesting.NestedProperty2}}; 78 | } 79 | 80 | When the project is built a new class is added called `DtmExtenstions.cs` which contains the mapper methods. 81 | 82 | More details and features to come later! 83 | 84 | ## How does it work? ## 85 | 86 | When you install the nuget package, it will add a `PreBuildEvent` in a `.targets` file which looks like: 87 | 88 | `"$(SolutionDir)packages\DesignTimeMapper.0.4.1\build\DesignTimeMapper.CommandLine.exe" "$(SolutionPath)" "$(MSBuildProjectName)"` 89 | 90 | Each time the project is built, the command line tool uses Roslyn to look for any classes with the `[MapFrom]` attribute. For each of these classes, it will create two extension methods to map from and to each class. That's about it really. 91 | 92 | ## The future ## 93 | 94 | At the moment it's quite basic. In the future it will do some more things like: 95 | - Checking that the mapped values are both readable/writable 96 | - Null checking (with nice exception throwing) 97 | - Generation of `Expression>`s to be used for mappings in Entity Framework queries 98 | - Optional type coersion (e.g. automatic generation of TryParse to go from a string to an int) 99 | - Custom pattern matching 100 | - Configurable extension file/class/method names 101 | - Performance improvements - it's probably not as effecient as it could be. Build time on projects with many mappings may currently be slow 102 | - Any other features that people request or are willing to contribute 103 | 104 | ## Known issues ## 105 | 106 | There are no checks for types during the mapping - so it may generate code that does not compile. 107 | Does not currently check that each property is writable - so again you may get generated code that does not compile. 108 | This is an early version so there are likely to be problems. Please open an issue with any details of the problem. -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/DesignTimeMapper.CommandLine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CBA34162-9A6C-412B-A0F9-D439EB3A29F2} 8 | Exe 9 | Properties 10 | DesignTimeMapper.CommandLine 11 | DesignTimeMapper.CommandLine 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | false 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll 41 | True 42 | 43 | 44 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll 45 | True 46 | 47 | 48 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 49 | True 50 | 51 | 52 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll 53 | True 54 | 55 | 56 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 57 | True 58 | 59 | 60 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll 61 | True 62 | 63 | 64 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll 65 | True 66 | 67 | 68 | ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll 69 | True 70 | 71 | 72 | 73 | ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll 74 | True 75 | 76 | 77 | ..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 78 | True 79 | 80 | 81 | 82 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll 83 | True 84 | 85 | 86 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll 87 | True 88 | 89 | 90 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll 91 | True 92 | 93 | 94 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll 95 | True 96 | 97 | 98 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll 99 | True 100 | 101 | 102 | ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll 103 | True 104 | 105 | 106 | 107 | ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll 108 | True 109 | 110 | 111 | ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll 112 | True 113 | 114 | 115 | ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll 116 | True 117 | 118 | 119 | ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll 120 | True 121 | 122 | 123 | 124 | ..\packages\System.Reflection.Metadata.1.4.1\lib\portable-net45+win8\System.Reflection.Metadata.dll 125 | True 126 | 127 | 128 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll 129 | True 130 | 131 | 132 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll 133 | True 134 | 135 | 136 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll 137 | True 138 | 139 | 140 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll 141 | True 142 | 143 | 144 | ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll 145 | True 146 | 147 | 148 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll 149 | True 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll 159 | True 160 | 161 | 162 | ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll 163 | True 164 | 165 | 166 | ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll 167 | True 168 | 169 | 170 | ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll 171 | True 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | {33e194b0-2638-4a3a-8701-379304ef0860} 193 | DesignTimeMapper.Engine 194 | 195 | 196 | 197 | 198 | copy /Y "$(TargetDir)$(ProjectName).exe" "$(SolutionDir)DesignTimeMapper\tools\$(ProjectName).exe" 199 | 200 | 201 | 202 | 203 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 204 | 205 | 206 | 207 | 214 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/DesignTimeMapper.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | DesignTimeMapperTarget 6 | $(BuildDependsOn); 7 | 8 | 9 | 10 | 11 | 12 | "C:\Development\DesignTimeMapper\DesignTimeMapper\DesignTimeMapper\bin\Debug\DesignTimeMapper.exe" $(SolutionPath) $(MSBuildProjectName) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using DesignTimeMapper.Engine.MapperGeneration; 4 | 5 | namespace DesignTimeMapper.CommandLine 6 | { 7 | class Program 8 | { 9 | private const int ErrorSuccess = 0; 10 | private const int ErrorInvalidFunction = 0x1; 11 | private const int ErrorFileNotFound = 0x2; 12 | private const int ErrorBadArguments = 0xA0; 13 | private const int ErrorInvalidCommandLine = 0x667; 14 | 15 | static int Main(string[] args) 16 | { 17 | if (args == null || args.Length != 2) 18 | { 19 | Console.Error.WriteLine("Error: DesignTimeMapper - Please provide a path to solution and a project name"); 20 | return ErrorInvalidCommandLine; 21 | } 22 | 23 | try 24 | { 25 | var path = args[0]; 26 | 27 | if (!File.Exists(path)) 28 | { 29 | Console.Error.WriteLine($"Error: Could not find .sln file at path '{path}'"); 30 | return ErrorFileNotFound; 31 | } 32 | 33 | var projectName = args[1]; 34 | if (string.IsNullOrWhiteSpace(projectName)) 35 | { 36 | Console.Error.WriteLine("Error: DesignTimeMapper - Project name cannot be empty"); 37 | return ErrorInvalidCommandLine; 38 | } 39 | 40 | var mapper = new Mapper(); 41 | mapper.Map(path, projectName).Wait(); 42 | } 43 | catch (Exception e) 44 | { 45 | Console.Error.WriteLine($"Error: Unexpected exception: {e}"); 46 | 47 | return ErrorInvalidFunction; 48 | } 49 | 50 | Console.WriteLine("Design Time Mapper - mapping completed successfully"); 51 | return ErrorSuccess; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DesignTimeMapper")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DesignTimeMapper")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("cba34162-9a6c-412b-a0f9-d439eb3a29f2")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.CommandLine/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/DesignTimeMapper.Engine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {33E194B0-2638-4A3A-8701-379304EF0860} 8 | Library 9 | Properties 10 | DesignTimeMapper.Engine 11 | DesignTimeMapper.Engine 12 | v4.6.1 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll 35 | True 36 | 37 | 38 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll 39 | True 40 | 41 | 42 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 43 | True 44 | 45 | 46 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll 47 | True 48 | 49 | 50 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 51 | True 52 | 53 | 54 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll 55 | True 56 | 57 | 58 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll 59 | True 60 | 61 | 62 | 63 | ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll 64 | True 65 | 66 | 67 | ..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 68 | True 69 | 70 | 71 | 72 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll 73 | True 74 | 75 | 76 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll 77 | True 78 | 79 | 80 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll 81 | True 82 | 83 | 84 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll 85 | True 86 | 87 | 88 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll 89 | True 90 | 91 | 92 | ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll 93 | True 94 | 95 | 96 | 97 | ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll 98 | True 99 | 100 | 101 | ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll 102 | True 103 | 104 | 105 | ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll 106 | True 107 | 108 | 109 | ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll 110 | True 111 | 112 | 113 | 114 | ..\packages\System.Reflection.Metadata.1.4.1\lib\portable-net45+win8\System.Reflection.Metadata.dll 115 | True 116 | 117 | 118 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll 119 | True 120 | 121 | 122 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll 123 | True 124 | 125 | 126 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll 127 | True 128 | 129 | 130 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll 131 | True 132 | 133 | 134 | ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll 135 | True 136 | 137 | 138 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll 139 | True 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll 149 | True 150 | 151 | 152 | ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll 153 | True 154 | 155 | 156 | ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll 157 | True 158 | 159 | 160 | ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll 161 | True 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | {a1c61131-b44d-4101-bcd7-9934e7be4d75} 187 | DesignTimeMapper 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 202 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Extensions/RoslynExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using Microsoft.CodeAnalysis; 3 | 4 | namespace DesignTimeMapper.Engine.Extensions 5 | { 6 | public static class RoslynExtensions 7 | { 8 | 9 | public static string GetFullMetadataName(this ISymbol symbol) 10 | { 11 | var sb = new StringBuilder(symbol.MetadataName); 12 | 13 | var last = symbol; 14 | symbol = symbol.ContainingSymbol; 15 | while (!IsRootNamespace(symbol)) 16 | { 17 | if (symbol is ITypeSymbol && last is ITypeSymbol) 18 | { 19 | sb.Insert(0, '+'); 20 | } 21 | else 22 | { 23 | sb.Insert(0, '.'); 24 | } 25 | sb.Insert(0, symbol.MetadataName); 26 | symbol = symbol.ContainingSymbol; 27 | } 28 | 29 | return sb.ToString(); 30 | } 31 | 32 | 33 | private static bool IsRootNamespace(ISymbol s) 34 | { 35 | return s is INamespaceSymbol && ((INamespaceSymbol)s).IsGlobalNamespace; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DesignTimeMapper.Engine.Extensions 4 | { 5 | public static class StringExtensions 6 | { 7 | public static string ToCamelCase(this string input) 8 | { 9 | if (input == null || input.Length < 2) 10 | return input; 11 | 12 | string[] words = input.Split( 13 | new char[] { }, 14 | StringSplitOptions.RemoveEmptyEntries); 15 | 16 | string result = words[0].ToLower(); 17 | for (int i = 1; i < words.Length; i++) 18 | { 19 | result += 20 | words[i].Substring(0, 1).ToUpper() + 21 | words[i].Substring(1); 22 | } 23 | 24 | return result; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Interface/IMapperMethodGenerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.CodeAnalysis; 3 | using Microsoft.CodeAnalysis.CSharp.Syntax; 4 | 5 | namespace DesignTimeMapper.Engine.Interface 6 | { 7 | public interface IMapperMethodGenerator 8 | { 9 | IList CreateMapperMethods(Compilation compilation); 10 | } 11 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/MapperGeneration/ClassMapper.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using DesignTimeMapper.Engine.Extensions; 4 | using DesignTimeMapper.Engine.Model; 5 | using Microsoft.CodeAnalysis; 6 | using Microsoft.CodeAnalysis.CSharp; 7 | using Microsoft.CodeAnalysis.CSharp.Syntax; 8 | using Microsoft.CodeAnalysis.Text; 9 | 10 | namespace DesignTimeMapper.Engine.MapperGeneration 11 | { 12 | public class ClassMapper 13 | { 14 | public const string MapperClassName = "DtmExtensions"; 15 | 16 | public SourceText CreateMapClass(IEnumerable methods, string namespaceName) 17 | { 18 | var newClass = SyntaxFactory.CompilationUnit() 19 | .WithMembers 20 | ( 21 | SyntaxFactory.List 22 | ( 23 | new MemberDeclarationSyntax[] 24 | { 25 | SyntaxFactory.NamespaceDeclaration(SyntaxFactory.IdentifierName(namespaceName)) 26 | .WithMembers( 27 | SyntaxFactory.SingletonList( 28 | SyntaxFactory.ClassDeclaration(MapperClassName) 29 | .WithMembers 30 | ( 31 | SyntaxFactory.List 32 | ( 33 | methods 34 | ) 35 | ) 36 | .WithModifiers( 37 | SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), 38 | SyntaxFactory.Token(SyntaxKind.StaticKeyword))) 39 | )) 40 | } 41 | ) 42 | ); 43 | 44 | newClass = newClass.AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName(nameof(System)))); 45 | 46 | return newClass.NormalizeWhitespace().GetText(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/MapperGeneration/Mapper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Threading.Tasks; 3 | using Microsoft.CodeAnalysis.MSBuild; 4 | 5 | namespace DesignTimeMapper.Engine.MapperGeneration 6 | { 7 | public class Mapper 8 | { 9 | /// 10 | /// Create the mapper class (DtmExtensions.cs). 11 | /// 12 | /// The path to the solution which contains the project you want to map classes in 13 | /// The name of the project to generate the mapper class for 14 | /// 15 | public async Task Map(string solutionPath, string projectName) 16 | { 17 | var msWorkspace = MSBuildWorkspace.Create(); 18 | var solution = await msWorkspace.OpenSolutionAsync(solutionPath); 19 | var project = solution.Projects.First(p => p.Name == projectName); 20 | var compilation = await project.GetCompilationAsync(); 21 | 22 | var mapperMethodGenerator = new MapperMethodGenerator(); 23 | var mappedMethods = mapperMethodGenerator.CreateMapperMethods(compilation); 24 | 25 | var classMapper = new ClassMapper(); 26 | var newClass = classMapper.CreateMapClass(mappedMethods, compilation.AssemblyName); 27 | 28 | var documentName = $"{ClassMapper.MapperClassName}.cs"; 29 | var existing = project.Documents.FirstOrDefault(d => d.Name == documentName); 30 | 31 | var document = existing == null 32 | ? project.AddDocument(documentName, newClass) 33 | : existing.WithText(newClass); 34 | 35 | msWorkspace.TryApplyChanges(document.Project.Solution); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/MapperGeneration/MapperMethodGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using DesignTimeMapper.Attributes; 5 | using DesignTimeMapper.Engine.Extensions; 6 | using DesignTimeMapper.Engine.Interface; 7 | using DesignTimeMapper.Engine.Model; 8 | using Microsoft.CodeAnalysis; 9 | using Microsoft.CodeAnalysis.CSharp; 10 | using Microsoft.CodeAnalysis.CSharp.Syntax; 11 | 12 | namespace DesignTimeMapper.Engine.MapperGeneration 13 | { 14 | public class MapperMethodGenerator : IMapperMethodGenerator 15 | { 16 | public IList CreateMapperMethods(Compilation compilation) 17 | { 18 | var methodDeclarationSyntaxs = new List(); 19 | 20 | foreach (var classToMapToTypeSymbol in GetClassesInCompilation(compilation)) 21 | foreach ( 22 | var attributeData in 23 | classToMapToTypeSymbol.GetAttributes().Where(a => a.AttributeClass.Name == nameof(MapFromAttribute))) 24 | { 25 | var type = attributeData.ConstructorArguments[0]; 26 | foreach (var typedConstant in type.Values) 27 | { 28 | var classToMapFromTypeSymbol = typedConstant.Value as INamedTypeSymbol; 29 | 30 | if (classToMapFromTypeSymbol != null) 31 | { 32 | var methods = CreateMapperMethods(classToMapToTypeSymbol, classToMapFromTypeSymbol); 33 | methodDeclarationSyntaxs.AddRange(methods); 34 | } 35 | } 36 | } 37 | 38 | return methodDeclarationSyntaxs; 39 | } 40 | 41 | internal IEnumerable GetClassesInCompilation(Compilation compilation) 42 | { 43 | foreach ( 44 | var result in 45 | compilation.SyntaxTrees 46 | .Select(syntaxTree => compilation.GetSemanticModel(syntaxTree)) 47 | .Select( 48 | semanticModel => 49 | semanticModel.SyntaxTree.GetRoot() 50 | .DescendantNodesAndSelf() 51 | .OfType() 52 | .Select( 53 | propertyDeclarationSyntax => 54 | semanticModel.GetDeclaredSymbol(propertyDeclarationSyntax)))) 55 | foreach (var namedTypeSymbol in result) 56 | yield return namedTypeSymbol; 57 | } 58 | 59 | private IEnumerable CreateMapperMethods(INamedTypeSymbol classToMapToTypeSymbol, 60 | INamedTypeSymbol classToMapFromTypeSymbol) 61 | { 62 | var inputArgName = classToMapFromTypeSymbol.Name.ToCamelCase(); 63 | string classToMapFromName = classToMapFromTypeSymbol.GetFullMetadataName(); 64 | 65 | var classToMapToSymbols = 66 | classToMapToTypeSymbol.GetMembers().Where(m => m.Kind == SymbolKind.Property).Cast(); 67 | var classToMapFromSymbols = 68 | classToMapFromTypeSymbol.GetMembers().Where(m => m.Kind == SymbolKind.Property).Cast(); 69 | 70 | //TODO handle case where expression syntaxes are empty 71 | var classToMapToName = classToMapToTypeSymbol.GetFullMetadataName(); 72 | 73 | var tree = GetMatchingPropertyTree(classToMapFromSymbols, classToMapToSymbols, inputArgName); 74 | 75 | var mapToMethodDeclaration = CreateMethodDeclaration(classToMapToTypeSymbol, classToMapToName, inputArgName, classToMapFromName, 76 | GetAssignmentExpressionSyntaxs(tree.MapToTree, inputArgName)); 77 | yield return mapToMethodDeclaration; 78 | 79 | var mapFromMethodDeclaration = CreateMethodDeclaration(classToMapFromTypeSymbol, classToMapFromName, inputArgName, classToMapToName, 80 | GetAssignmentExpressionSyntaxs(tree.MapFromTree, inputArgName)); 81 | yield return mapFromMethodDeclaration; 82 | } 83 | 84 | private static MethodDeclarationSyntax CreateMethodDeclaration(INamedTypeSymbol classToMapToTypeSymbol, 85 | string classToMapToName, string inputArgName, string classToMapFromName, IEnumerable expressionSyntaxs) 86 | { 87 | var methodDeclaration = SyntaxFactory.MethodDeclaration 88 | ( 89 | SyntaxFactory.IdentifierName(classToMapToName), 90 | SyntaxFactory.Identifier("MapTo" + classToMapToTypeSymbol.Name) 91 | ) 92 | .WithModifiers 93 | ( 94 | SyntaxFactory.TokenList 95 | (SyntaxFactory.Token(SyntaxKind.PublicKeyword), 96 | SyntaxFactory.Token(SyntaxKind.StaticKeyword)) 97 | ) 98 | .WithParameterList 99 | ( 100 | SyntaxFactory.ParameterList 101 | ( 102 | SyntaxFactory.SeparatedList( 103 | new[] 104 | { 105 | SyntaxFactory.Parameter 106 | ( 107 | SyntaxFactory.Identifier(inputArgName) 108 | ) 109 | .WithType 110 | ( 111 | SyntaxFactory.IdentifierName(classToMapFromName) 112 | ) 113 | .WithModifiers 114 | ( 115 | SyntaxTokenList.Create(SyntaxFactory.Token(SyntaxKind.ThisKeyword)) 116 | ) 117 | } 118 | ) 119 | ) 120 | ) 121 | .WithBody 122 | ( 123 | SyntaxFactory.Block(SyntaxFactory.TryStatement(ReturnBlock(classToMapToName, expressionSyntaxs), SyntaxFactory.SingletonList(SyntaxFactory.CatchClause(SyntaxFactory.CatchDeclaration(SyntaxFactory.ParseTypeName(nameof(NullReferenceException))), null, DefaultReturnBlock(classToMapToName))), null)) 124 | ); 125 | return methodDeclaration; 126 | } 127 | 128 | private static BlockSyntax ReturnBlock(string classToMapToName, IEnumerable expressionSyntaxs) 129 | { 130 | return SyntaxFactory.Block 131 | ( 132 | SyntaxFactory.SingletonList 133 | ( 134 | SyntaxFactory.ReturnStatement 135 | ( 136 | SyntaxFactory.ObjectCreationExpression 137 | ( 138 | SyntaxFactory.IdentifierName(classToMapToName) 139 | ) 140 | .WithArgumentList 141 | ( 142 | SyntaxFactory.ArgumentList() 143 | ) 144 | .WithInitializer 145 | ( 146 | SyntaxFactory.InitializerExpression 147 | ( 148 | SyntaxKind.ObjectInitializerExpression, 149 | SyntaxFactory.SeparatedList 150 | ( 151 | expressionSyntaxs 152 | ) 153 | ) 154 | ) 155 | ) 156 | ) 157 | ); 158 | } 159 | 160 | /// 161 | /// Create a "return default(className);" syntax block 162 | /// 163 | /// 164 | /// 165 | private static BlockSyntax DefaultReturnBlock(string className) 166 | { 167 | //TODO move to extensions class? 168 | return SyntaxFactory.Block 169 | ( 170 | SyntaxFactory.SingletonList 171 | ( 172 | SyntaxFactory.ReturnStatement 173 | ( 174 | SyntaxFactory.DefaultExpression(SyntaxFactory.ParseTypeName(className)) 175 | ) 176 | ) 177 | ); 178 | } 179 | 180 | private MatchingPropertyTree GetMatchingPropertyTree(IEnumerable classToMapFromSymbols, IEnumerable classToMapToSymbols, string inputArgName) 181 | { 182 | var mapToTree = new MapTreeNode(null); 183 | var mapFromTree = new MapTreeNode(null); 184 | 185 | BuildMatchingPropertyTree(classToMapToSymbols, mapToTree, classToMapFromSymbols, mapFromTree); 186 | 187 | var matchingPropertyTree = new MatchingPropertyTree 188 | { 189 | MapFromTree = mapFromTree, 190 | MapToTree = mapToTree 191 | }; 192 | return matchingPropertyTree; 193 | } 194 | 195 | 196 | private void BuildMatchingPropertyTree(IEnumerable classToMapToSymbols, MapTreeNode mapToNode, IEnumerable classToMapFromSymbols, MapTreeNode mapFromNode) 197 | { 198 | foreach (var classToMapToSymbol in classToMapToSymbols) 199 | { 200 | var mapToChild = mapToNode.AddOrGetChild(classToMapToSymbol); 201 | if(mapToChild.MapsTo != null) continue; 202 | 203 | string potentialName = string.Empty; 204 | mapToChild.TraverseAncestors(s => potentialName = potentialName.Insert(0, s.Name)); 205 | 206 | foreach (var classToMapFromSymbol in classToMapFromSymbols) 207 | { 208 | var mapFromChild = mapFromNode.AddOrGetChild(classToMapFromSymbol); 209 | if (potentialName == classToMapFromSymbol.Name) 210 | { 211 | mapToChild.AddMapping(mapFromChild); 212 | break; 213 | } 214 | if(potentialName.StartsWith(classToMapFromSymbol.Name)) 215 | { 216 | IPropertySymbol mapFromChildProperty = GetMatchingChild(mapFromChild, potentialName, 217 | classToMapFromSymbol.Type.GetMembers() 218 | .Where(m => m.Kind == SymbolKind.Property) 219 | .Cast()); 220 | 221 | if (mapFromChildProperty != null) 222 | { 223 | var mapFromChildChild = mapFromChild.AddChild(mapFromChildProperty); 224 | mapToChild.AddMapping(mapFromChildChild); 225 | break; 226 | } 227 | } 228 | if (classToMapFromSymbol.Name.StartsWith(potentialName)) 229 | { 230 | var childSymbols = classToMapToSymbol.Type.GetMembers().Where(m => m.Kind == SymbolKind.Property).Cast(); 231 | BuildMatchingPropertyTree(childSymbols, mapToChild, classToMapFromSymbols, mapFromNode); 232 | } 233 | } 234 | } 235 | } 236 | 237 | private IPropertySymbol GetMatchingChild(MapTreeNode parent, string potentialName, IEnumerable propertySymbols) 238 | { 239 | foreach (var propertySymbol in propertySymbols) 240 | { 241 | var potentialMappedName = string.Empty; 242 | parent.TraverseAncestors(s => potentialMappedName = potentialMappedName.Insert(0, s.Name)); 243 | potentialMappedName += propertySymbol.Name; 244 | 245 | if (potentialName == potentialMappedName) 246 | return propertySymbol; 247 | } 248 | return null; 249 | } 250 | 251 | private static IEnumerable GetAssignmentExpressionSyntaxs( 252 | MapTreeNode node, string inputArgName) 253 | { 254 | foreach (var child in node.Children) 255 | { 256 | if (child.Children.Any()) 257 | { 258 | var separatedSyntaxList = new SeparatedSyntaxList(); 259 | foreach (var assignmentExpressionSyntax in GetAssignmentExpressionSyntaxs(child, inputArgName)) 260 | { 261 | separatedSyntaxList = separatedSyntaxList.Add(assignmentExpressionSyntax); 262 | } 263 | 264 | yield return SyntaxFactory.AssignmentExpression 265 | ( 266 | SyntaxKind 267 | .SimpleAssignmentExpression, 268 | SyntaxFactory.IdentifierName(child.Value.Name), 269 | SyntaxFactory.ObjectCreationExpression( 270 | SyntaxFactory.IdentifierName(child.Value.Type.GetFullMetadataName()), 271 | SyntaxFactory.ArgumentList(), SyntaxFactory.InitializerExpression(SyntaxKind.ObjectInitializerExpression, separatedSyntaxList))); 272 | 273 | 274 | } 275 | else if(HasValidMapping(child)) 276 | { 277 | //TODO better way of getting the name 278 | var ancestors = child.MapsTo.GetAncestors(); 279 | var name = string.Join(".", ancestors.Select(a => a.Name)) + "." + child.MapsTo.Value.Name; 280 | if (name.StartsWith(".")) name = name.Remove(0, 1); 281 | 282 | yield return SyntaxFactory.AssignmentExpression 283 | ( 284 | SyntaxKind 285 | .SimpleAssignmentExpression, 286 | SyntaxFactory.IdentifierName(child.Value.Name), 287 | SyntaxFactory.MemberAccessExpression 288 | ( 289 | SyntaxKind 290 | .SimpleMemberAccessExpression, 291 | SyntaxFactory.IdentifierName(inputArgName), 292 | SyntaxFactory.IdentifierName(name) 293 | ) 294 | ); 295 | } 296 | } 297 | } 298 | 299 | private static bool HasValidMapping(MapTreeNode child) 300 | { 301 | var hasMapping = child.MapsTo != null; 302 | 303 | if (!hasMapping) return false; 304 | 305 | var childHasDoNotMapAttribute = child.Value.GetAttributes().Any(a => a.AttributeClass.Name == nameof(DoNotMapAttribute)); 306 | var mapsToHasDoNotMapAttribute = child.MapsTo.Value.GetAttributes().Any(a => a.AttributeClass.Name == nameof(DoNotMapAttribute)); 307 | return !childHasDoNotMapAttribute && 308 | !mapsToHasDoNotMapAttribute; 309 | } 310 | } 311 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Model/MapTreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | 7 | namespace DesignTimeMapper.Engine.Model 8 | { 9 | [DebuggerDisplay("Value = {Value}")] 10 | public class MapTreeNode 11 | { 12 | private readonly T _value; 13 | private readonly List> _children = new List>(); 14 | 15 | public MapTreeNode(T value) 16 | { 17 | _value = value; 18 | } 19 | 20 | public MapTreeNode this[int i] 21 | { 22 | get { return _children[i]; } 23 | } 24 | 25 | public MapTreeNode Parent { get; private set; } 26 | 27 | public T Value { get { return _value; } } 28 | 29 | public MapTreeNode MapsTo { get; private set; } 30 | 31 | public void AddMapping(MapTreeNode mapped) 32 | { 33 | MapsTo = mapped; 34 | mapped.MapsTo = this; 35 | } 36 | 37 | public ReadOnlyCollection> Children 38 | { 39 | get { return _children.AsReadOnly(); } 40 | } 41 | 42 | public MapTreeNode AddChild(T value) 43 | { 44 | var node = new MapTreeNode(value) { Parent = this }; 45 | _children.Add(node); 46 | return node; 47 | } 48 | 49 | public MapTreeNode AddOrGetChild(T value) 50 | { 51 | foreach (var mapTreeNode in Children) 52 | { 53 | if (mapTreeNode.Value.Equals(value)) 54 | return mapTreeNode; 55 | } 56 | 57 | var node = new MapTreeNode(value) { Parent = this }; 58 | _children.Add(node); 59 | return node; 60 | } 61 | 62 | public MapTreeNode[] AddChildren(params T[] values) 63 | { 64 | return values.Select(AddChild).ToArray(); 65 | } 66 | 67 | public bool RemoveChild(MapTreeNode node) 68 | { 69 | return _children.Remove(node); 70 | } 71 | 72 | public void Traverse(Action action) 73 | { 74 | action(Value); 75 | foreach (var child in _children) 76 | child.Traverse(action); 77 | } 78 | 79 | public void TraverseAncestors(Action action) 80 | { 81 | if(Value!= null) 82 | action(Value); 83 | 84 | if (Parent != null) 85 | { 86 | Parent.TraverseAncestors(action); 87 | } 88 | } 89 | 90 | public IEnumerable GetAncestors() 91 | { 92 | if (Parent != null) 93 | { 94 | if(Parent.Value != null) 95 | yield return Parent.Value; 96 | 97 | foreach (var ancestor in Parent.GetAncestors()) 98 | { 99 | yield return ancestor; 100 | } 101 | } 102 | } 103 | 104 | public IEnumerable Flatten() 105 | { 106 | return new[] { Value }.Union(_children.SelectMany(x => x.Flatten())); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Model/MatchingPropertyTree.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace DesignTimeMapper.Engine.Model 4 | { 5 | public class MatchingPropertyTree 6 | { 7 | public MapTreeNode MapFromTree { get; set; } 8 | public MapTreeNode MapToTree { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DesignTimeMapper.Engine")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DesignTimeMapper.Engine")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("33e194b0-2638-4a3a-8701-379304ef0860")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("0.4.1")] 35 | [assembly: AssemblyFileVersion("0.4.1")] 36 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/Settings/DtmSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DesignTimeMapper.Engine.Settings 4 | { 5 | public class DtmSettings 6 | { 7 | public List SourceFiles { get; set; } 8 | public string DestinationProject { get; set; } 9 | public string MappedClassPrefix { get; set; } 10 | public string MappedClassSuffix { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Engine/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/AddressDto.cs: -------------------------------------------------------------------------------- 1 | using System.Device.Location; 2 | using DesignTimeMapper.Attributes; 3 | 4 | namespace DesignTimeMapper.ExamplePocos 5 | { 6 | [MapFrom(typeof(CivicAddress))] 7 | public class AddressDto 8 | { 9 | public string AddressLine1 { get; set; } 10 | public string AddressLine2 { get; set; } 11 | public string Building { get; set; } 12 | public string City { get; set; } 13 | public string PostalCode { get; set; } 14 | public string StateProvince { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/ClassWithExternalReference.cs: -------------------------------------------------------------------------------- 1 | namespace DesignTimeMapper.ExamplePocos 2 | { 3 | public class ClassWithExternalReference 4 | { 5 | 6 | } 7 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/DesignTimeMapper.ExamplePocos.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1A3A0380-42B8-4315-8703-92CD5E3BED08} 8 | Library 9 | Properties 10 | DesignTimeMapper.ExamplePocos 11 | DesignTimeMapper.ExamplePocos 12 | v4.6.1 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll 37 | True 38 | 39 | 40 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll 41 | True 42 | 43 | 44 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 45 | True 46 | 47 | 48 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll 49 | True 50 | 51 | 52 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 53 | True 54 | 55 | 56 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll 57 | True 58 | 59 | 60 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll 61 | True 62 | 63 | 64 | 65 | ..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll 66 | True 67 | 68 | 69 | ..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 70 | True 71 | 72 | 73 | 74 | ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll 75 | True 76 | 77 | 78 | ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll 79 | True 80 | 81 | 82 | ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll 83 | True 84 | 85 | 86 | ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll 87 | True 88 | 89 | 90 | ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll 91 | True 92 | 93 | 94 | ..\packages\System.Console.4.0.0\lib\net46\System.Console.dll 95 | True 96 | 97 | 98 | 99 | 100 | ..\packages\System.Diagnostics.FileVersionInfo.4.0.0\lib\net46\System.Diagnostics.FileVersionInfo.dll 101 | True 102 | 103 | 104 | ..\packages\System.Diagnostics.StackTrace.4.0.1\lib\net46\System.Diagnostics.StackTrace.dll 105 | True 106 | 107 | 108 | ..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll 109 | True 110 | 111 | 112 | ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll 113 | True 114 | 115 | 116 | 117 | ..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll 118 | True 119 | 120 | 121 | ..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll 122 | True 123 | 124 | 125 | ..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll 126 | True 127 | 128 | 129 | ..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll 130 | True 131 | 132 | 133 | ..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll 134 | True 135 | 136 | 137 | ..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll 138 | True 139 | 140 | 141 | ..\packages\System.Threading.Thread.4.0.0\lib\net46\System.Threading.Thread.dll 142 | True 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll 152 | True 153 | 154 | 155 | ..\packages\System.Xml.XmlDocument.4.0.1\lib\net46\System.Xml.XmlDocument.dll 156 | True 157 | 158 | 159 | ..\packages\System.Xml.XPath.4.0.1\lib\net46\System.Xml.XPath.dll 160 | True 161 | 162 | 163 | ..\packages\System.Xml.XPath.XDocument.4.0.1\lib\net46\System.Xml.XPath.XDocument.dll 164 | True 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | {a1c61131-b44d-4101-bcd7-9934e7be4d75} 189 | DesignTimeMapper 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 204 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/DtmExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace DesignTimeMapper.ExamplePocos 2 | { 3 | public static class DtmExtensions 4 | { 5 | public static DesignTimeMapper.ExamplePocos.AddressDto MapToAddressDto(this System.Device.Location.CivicAddress civicaddress) 6 | { 7 | return new DesignTimeMapper.ExamplePocos.AddressDto() 8 | {AddressLine1 = civicaddress.AddressLine1, AddressLine2 = civicaddress.AddressLine2, Building = civicaddress.Building, City = civicaddress.City, PostalCode = civicaddress.PostalCode, StateProvince = civicaddress.StateProvince}; 9 | } 10 | 11 | public static System.Device.Location.CivicAddress MapToCivicAddress(this DesignTimeMapper.ExamplePocos.AddressDto civicaddress) 12 | { 13 | return new System.Device.Location.CivicAddress() 14 | {AddressLine1 = civicaddress.AddressLine1, AddressLine2 = civicaddress.AddressLine2, Building = civicaddress.Building, City = civicaddress.City, PostalCode = civicaddress.PostalCode, StateProvince = civicaddress.StateProvince}; 15 | } 16 | 17 | public static DesignTimeMapper.ExamplePocos.NestedClassDto MapToNestedClassDto(this NestedClass nestedclass) 18 | { 19 | return new DesignTimeMapper.ExamplePocos.NestedClassDto() 20 | {NestedProperty1 = nestedclass.Nested.Property1, NestedProperty2 = nestedclass.Nested.Property2}; 21 | } 22 | 23 | public static NestedClass MapToNestedClass(this DesignTimeMapper.ExamplePocos.NestedClassDto nestedclass) 24 | { 25 | return new NestedClass() 26 | {Nested = new DesignTimeMapper.ExamplePocos.SimpleClass() 27 | {Property1 = nestedclass.NestedProperty1, Property2 = nestedclass.NestedProperty2}}; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/NestedClass.cs: -------------------------------------------------------------------------------- 1 | namespace DesignTimeMapper.ExamplePocos 2 | { 3 | public class NestedClass 4 | { 5 | public string Property1 { get; set; } 6 | public SimpleClass Nested { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/NestedClassDto.cs: -------------------------------------------------------------------------------- 1 | using DesignTimeMapper.Attributes; 2 | 3 | namespace DesignTimeMapper.ExamplePocos 4 | { 5 | [MapFrom(typeof(NestedClass))] 6 | public class NestedClassDto 7 | { 8 | [DoNotMap] 9 | public string Property1 { get; set; } 10 | public int NestedProperty1 { get; set; } 11 | public string NestedProperty2 { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DesignTimeMapper.ExamplePocos")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DesignTimeMapper.ExamplePocos")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("1a3a0380-42b8-4315-8703-92cd5e3bed08")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/SimpleClass.cs: -------------------------------------------------------------------------------- 1 | namespace DesignTimeMapper.ExamplePocos 2 | { 3 | public class SimpleClass 4 | { 5 | public int Property1 { get; set; } 6 | public string Property2 { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.ExamplePocos/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/DesignTimeMapper.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {DAF50090-691E-4851-9116-EE770D822556} 7 | Library 8 | Properties 9 | DesignTimeMapper.Tests 10 | DesignTimeMapper.Tests 11 | v4.6.1 12 | 512 13 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 10.0 15 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 16 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages 17 | False 18 | UnitTest 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll 40 | True 41 | 42 | 43 | ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll 44 | True 45 | 46 | 47 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.Workspaces.dll 48 | True 49 | 50 | 51 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.dll 52 | True 53 | 54 | 55 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.2\lib\net45\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll 56 | True 57 | 58 | 59 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.dll 60 | True 61 | 62 | 63 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll 64 | True 65 | 66 | 67 | 68 | ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll 69 | True 70 | 71 | 72 | ..\packages\System.Collections.Immutable.1.3.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll 73 | True 74 | 75 | 76 | 77 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll 78 | True 79 | 80 | 81 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll 82 | True 83 | 84 | 85 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll 86 | True 87 | 88 | 89 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll 90 | True 91 | 92 | 93 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll 94 | True 95 | 96 | 97 | ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll 98 | True 99 | 100 | 101 | ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll 102 | True 103 | 104 | 105 | ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll 106 | True 107 | 108 | 109 | ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll 110 | True 111 | 112 | 113 | ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll 114 | True 115 | 116 | 117 | 118 | ..\packages\System.Reflection.Metadata.1.4.1\lib\portable-net45+win8\System.Reflection.Metadata.dll 119 | True 120 | 121 | 122 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll 123 | True 124 | 125 | 126 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll 127 | True 128 | 129 | 130 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll 131 | True 132 | 133 | 134 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll 135 | True 136 | 137 | 138 | ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll 139 | True 140 | 141 | 142 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll 143 | True 144 | 145 | 146 | 147 | 148 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll 149 | True 150 | 151 | 152 | ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll 153 | True 154 | 155 | 156 | ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll 157 | True 158 | 159 | 160 | ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll 161 | True 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | False 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | {33e194b0-2638-4a3a-8701-379304ef0860} 195 | DesignTimeMapper.Engine 196 | 197 | 198 | 199 | 200 | 201 | 202 | False 203 | 204 | 205 | False 206 | 207 | 208 | False 209 | 210 | 211 | False 212 | 213 | 214 | 215 | 216 | 217 | 218 | 225 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/Integration/MapperMethodGeneratorIntegrationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using DesignTimeMapper.Engine.MapperGeneration; 3 | using Microsoft.CodeAnalysis.MSBuild; 4 | using Microsoft.VisualStudio.TestTools.UnitTesting; 5 | 6 | namespace DesignTimeMapper.Tests.Integration 7 | { 8 | [TestClass] 9 | public class MapperMethodGeneratorIntegrationTests 10 | { 11 | private const string ProjectFilePath = @"C:\Development\DesignTimeMapper\DesignTimeMapper\DesignTimeMapper.ExamplePocos\DesignTimeMapper.ExamplePocos.csproj"; 12 | 13 | [TestMethod] 14 | public async Task TestMethod1() 15 | { 16 | var msWorkspace = MSBuildWorkspace.Create(); 17 | 18 | //TODO - not hardcoded 19 | var project = await msWorkspace.OpenProjectAsync(ProjectFilePath); 20 | var compilation = await project.GetCompilationAsync(); 21 | 22 | var mapperMethodGenerator = new MapperMethodGenerator(); 23 | var mappedMethods = mapperMethodGenerator.CreateMapperMethods(compilation); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/Integration/SimpleClassIntegrationTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace DesignTimeMapper.Tests.Integration 4 | { 5 | [TestClass] 6 | public class SimpleClassIntegrationTests 7 | { 8 | [TestMethod] 9 | public void TestMethod1() 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("DesignTimeMapper.Engine.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("DesignTimeMapper.Engine.Tests")] 12 | [assembly: AssemblyCopyright("Copyright © 2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("daf50090-691e-4851-9116-ee770d822556")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/Unit/MapperMethodGeneratorTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace DesignTimeMapper.Tests.Unit 4 | { 5 | [TestClass] 6 | public class MapperMethodGeneratorTests 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignTimeMapper.ExamplePocos", "DesignTimeMapper.ExamplePocos\DesignTimeMapper.ExamplePocos.csproj", "{1A3A0380-42B8-4315-8703-92CD5E3BED08}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignTimeMapper.CommandLine", "DesignTimeMapper.CommandLine\DesignTimeMapper.CommandLine.csproj", "{CBA34162-9A6C-412B-A0F9-D439EB3A29F2}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignTimeMapper", "DesignTimeMapper\DesignTimeMapper.csproj", "{A1C61131-B44D-4101-BCD7-9934E7BE4D75}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignTimeMapper.Engine", "DesignTimeMapper.Engine\DesignTimeMapper.Engine.csproj", "{33E194B0-2638-4A3A-8701-379304EF0860}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {1A3A0380-42B8-4315-8703-92CD5E3BED08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {1A3A0380-42B8-4315-8703-92CD5E3BED08}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {1A3A0380-42B8-4315-8703-92CD5E3BED08}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {1A3A0380-42B8-4315-8703-92CD5E3BED08}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {CBA34162-9A6C-412B-A0F9-D439EB3A29F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {CBA34162-9A6C-412B-A0F9-D439EB3A29F2}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {CBA34162-9A6C-412B-A0F9-D439EB3A29F2}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {CBA34162-9A6C-412B-A0F9-D439EB3A29F2}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {A1C61131-B44D-4101-BCD7-9934E7BE4D75}.Debug|Any CPU.ActiveCfg = Debug 3.5|Any CPU 29 | {A1C61131-B44D-4101-BCD7-9934E7BE4D75}.Debug|Any CPU.Build.0 = Debug 3.5|Any CPU 30 | {A1C61131-B44D-4101-BCD7-9934E7BE4D75}.Release|Any CPU.ActiveCfg = Release 4.5|Any CPU 31 | {A1C61131-B44D-4101-BCD7-9934E7BE4D75}.Release|Any CPU.Build.0 = Release 4.5|Any CPU 32 | {33E194B0-2638-4A3A-8701-379304EF0860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {33E194B0-2638-4A3A-8701-379304EF0860}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {33E194B0-2638-4A3A-8701-379304EF0860}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {33E194B0-2638-4A3A-8701-379304EF0860}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/Attributes/DoNotMapAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DesignTimeMapper.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Property)] 6 | public class DoNotMapAttribute : Attribute 7 | { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/Attributes/MapFromAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DesignTimeMapper.Attributes 4 | { 5 | [AttributeUsage(AttributeTargets.Class)] 6 | public class MapFromAttribute : Attribute 7 | { 8 | public Type[] Types { get; set; } 9 | 10 | public MapFromAttribute(params Type[] types) 11 | { 12 | Types = types; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/DesignTimeMapper.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A1C61131-B44D-4101-BCD7-9934E7BE4D75} 8 | Library 9 | Properties 10 | DesignTimeMapper 11 | DesignTimeMapper 12 | 512 13 | bin\Debug\net35\ 14 | 15 | 16 | true 17 | full 18 | false 19 | DEBUG;TRACE 20 | prompt 21 | 4 22 | bin\Debug\net35\ 23 | v3.5 24 | 25 | 26 | pdbonly 27 | true 28 | TRACE 29 | prompt 30 | 4 31 | bin\Release\net35\ 32 | v3.5 33 | 34 | 35 | pdbonly 36 | true 37 | TRACE 38 | prompt 39 | 4 40 | bin\Release\net40\ 41 | v4.0 42 | 43 | 44 | pdbonly 45 | true 46 | bin\Release\ 47 | TRACE 48 | prompt 49 | 4 50 | bin\Release\net45\ 51 | v4.5 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Designer 70 | 71 | 72 | 73 | 74 | 75 | 76 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/DesignTimeMapper.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $id$ 5 | 0.4.1 6 | $title$ 7 | Alistair Clark 8 | Alistair Clark 9 | https://opensource.org/licenses/MIT 10 | https://github.com/AlistairClark7/DesignTimeMapper 11 | false 12 | Tool that uses Roslyn to automatically create object-object mapper methods 13 | Support for nested properties on class with MapFrom attribute 14 | Copyright 2017 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DesignTimeMapper")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DesignTimeMapper")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a1c61131-b44d-4101-bcd7-9934e7be4d75")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.4.1")] 36 | [assembly: AssemblyFileVersion("0.4.1")] 37 | -------------------------------------------------------------------------------- /Source/DesignTimeMapper/DesignTimeMapper/build/DesignTimeMapper.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | DesignTimeMapperTarget; 6 | $(BuildDependsOn) 7 | 8 | 9 | 10 | 11 | "$(SolutionDir)packages\DesignTimeMapper.0.4.1\build\DesignTimeMapper.CommandLine.exe" "$(SolutionPath)" "$(MSBuildProjectName)" 12 | 13 | 14 | --------------------------------------------------------------------------------