Skip to content

Commit f3e69e0

Browse files
Merge pull request #3 from jithinjosepkl/master
NetworkDirect 2.0 Interface, util library, examples, and unit-tests
2 parents 01e7657 + 01a8245 commit f3e69e0

125 files changed

Lines changed: 19501 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.build/CBT/CBT.Core.dll

2.27 MB
Binary file not shown.

.build/CBT/build.props

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project InitialTargets="ShowCBTParseErrors;RestoreCBTModules" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<!-- Ensures that if this file changes, projects will be rebuilt -->
6+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
7+
8+
<EnlistmentRoot Condition=" '$(EnlistmentRoot)' != '' ">$(EnlistmentRoot.TrimEnd('\\'))</EnlistmentRoot>
9+
10+
<!-- Default CBT global to this directory if not specified -->
11+
<CBTGlobalPath Condition=" '$(CBTGlobalPath)' == '' ">$(MSBuildThisFileDirectory)</CBTGlobalPath>
12+
<CBTGlobalPath>$(CBTGlobalPath.TrimEnd('\\'))</CBTGlobalPath>
13+
14+
<!-- Default CBT local to ..\Local if not specified -->
15+
<CBTLocalPath Condition=" '$(CBTLocalPath)' == '' And Exists('$([System.IO.Path]::GetDirectoryName($(CBTGlobalPath)))\Local') ">$([System.IO.Path]::GetDirectoryName($(CBTGlobalPath)))\Local</CBTLocalPath>
16+
<CBTLocalPath>$(CBTLocalPath.TrimEnd('\\'))</CBTLocalPath>
17+
18+
<CBTLocalBuildExtensionsPath Condition=" '$(CBTLocalBuildExtensionsPath)' == '' And '$(CBTLocalPath)' != '' And Exists('$(CBTLocalPath)\Extensions') ">$(CBTLocalPath)\Extensions</CBTLocalBuildExtensionsPath>
19+
20+
<DefaultProjectConfiguration Condition=" '$(DefaultProjectConfiguration)' == '' ">Debug</DefaultProjectConfiguration>
21+
<Configuration Condition=" '$(Configuration)' == '' And '$(DefaultProjectConfiguration)' != '' ">$(DefaultProjectConfiguration)</Configuration>
22+
<Platform Condition=" '$(Platform)' == '' And '$(DefaultProjectPlatform)' != '' ">$(DefaultProjectPlatform)</Platform>
23+
</PropertyGroup>
24+
25+
<Import Project="$(CBTLocalBuildExtensionsPath)\Before.$(MSBuildThisFile)" Condition=" '$(CBTLocalBuildExtensionsPath)' != '' And Exists('$(CBTLocalBuildExtensionsPath)\Before.$(MSBuildThisFile)') " />
26+
27+
<PropertyGroup>
28+
<CBTModulePackageConfigPath Condition=" '$(CBTModulePackageConfigPath)' == '' And '$(CBTLocalPath)' != '' And Exists('$(CBTLocalPath)\CBTModules\CBTModules.proj') ">$([System.IO.Path]::Combine($(CBTLocalPath), 'CBTModules', 'CBTModules.proj'))</CBTModulePackageConfigPath>
29+
<CBTModulePackageConfigPath Condition=" '$(CBTModulePackageConfigPath)' == '' And '$(CBTLocalPath)' != '' And Exists('$(CBTLocalPath)\CBTModules.proj') ">$([System.IO.Path]::Combine($(CBTLocalPath), 'CBTModules.proj'))</CBTModulePackageConfigPath>
30+
<CBTModulePackageConfigPath Condition=" '$(CBTModulePackageConfigPath)' == '' And '$(CBTLocalPath)' != '' And Exists('$(CBTLocalPath)\CBTModules\packages.config') ">$([System.IO.Path]::Combine($(CBTLocalPath), 'CBTModules', 'packages.config'))</CBTModulePackageConfigPath>
31+
<CBTModulePackageConfigPath Condition=" '$(CBTModulePackageConfigPath)' == '' And '$(CBTLocalPath)' != '' And Exists('$(CBTLocalPath)\packages.config') ">$([System.IO.Path]::Combine($(CBTLocalPath), 'packages.config'))</CBTModulePackageConfigPath>
32+
<CBTModulePackageConfigPath Condition=" '$(CBTModulePackageConfigPath)' != '' ">$([System.IO.Path]::GetFullPath($(CBTModulePackageConfigPath)))</CBTModulePackageConfigPath>
33+
</PropertyGroup>
34+
35+
<PropertyGroup>
36+
<CBTCoreAssemblyPath Condition=" '$(CBTCoreAssemblyPath)' == '' ">$(MSBuildThisFileDirectory)CBT.Core.dll</CBTCoreAssemblyPath>
37+
<CBTModuleRestoreInputs Condition=" '$(CBTModuleRestoreInputs)' == '' ">$(MSBuildThisFileFullPath);$(CBTCoreAssemblyPath);$(CBTModulePackageConfigPath)</CBTModuleRestoreInputs>
38+
</PropertyGroup>
39+
40+
<!-- Load modules -->
41+
42+
<PropertyGroup Condition=" '$(EnlistmentRoot)' != '' And '$(CBTModulePackageConfigPath)' != '' ">
43+
<CBTIntermediateOutputPath Condition=" '$(CBTIntermediateOutputPath)' == '' ">$(MSBuildThisFileDirectory)obj</CBTIntermediateOutputPath>
44+
45+
<CBTModulePath Condition=" '$(CBTModulePath)' == '' ">$(CBTIntermediateOutputPath)\Modules</CBTModulePath>
46+
<CBTModulePropertiesFile Condition=" '$(CBTModulePropertiesFile)' == '' ">$(CBTModulePath)\$(MSBuildThisFile)</CBTModulePropertiesFile>
47+
<CBTModuleExtensionsPath Condition=" '$(CBTModuleExtensionsPath)' == '' ">$(CBTModulePath)\Extensions</CBTModuleExtensionsPath>
48+
<CBTModuleImportsBefore Condition=" '$(CBTModuleImportsBefore)' == '' ">%24(CBTLocalBuildExtensionsPath)\%24(MSBuildThisFile)</CBTModuleImportsBefore>
49+
<CBTModuleImportsAfter Condition=" '$(CBTModuleImportsAfter)' == '' "></CBTModuleImportsAfter>
50+
51+
<CBTNuGetBinDir Condition=" '$(CBTNuGetBinDir)' == '' ">$(CBTIntermediateOutputPath)\NuGet</CBTNuGetBinDir>
52+
<CBTNuGetDownloaderAssemblyPath Condition=" '$(CBTNuGetDownloaderAssemblyPath)' == '' ">$(CBTCoreAssemblyPath)</CBTNuGetDownloaderAssemblyPath>
53+
<CBTNuGetDownloaderClassName Condition=" '$(CBTNuGetDownloaderClassName)' == '' ">CBT.Core.Internal.DefaultNuGetDownloader</CBTNuGetDownloaderClassName>
54+
<CBTModuleRestoreTaskName Condition=" '$(CBTModuleRestoreTaskName)' == '' ">CBT.Core.Tasks.RestoreModules</CBTModuleRestoreTaskName>
55+
<CBTModuleRestoreCommand Condition=" '$(CBTModuleRestoreCommand)' == '' ">$(CBTNuGetBinDir)\NuGet.exe</CBTModuleRestoreCommand>
56+
<CBTModuleRestoreCommandArguments Condition=" '$(CBTModuleRestoreCommandArguments)' == '' ">restore &quot;$(CBTModulePackageConfigPath)&quot; -NonInteractive</CBTModuleRestoreCommandArguments>
57+
<CBTModuleRestoreCommandArguments Condition=" '$(CBTModuleRestoreCommandAdditionalArguments)' != '' ">$(CBTModuleRestoreCommandArguments) $(CBTModuleRestoreCommandAdditionalArguments)</CBTModuleRestoreCommandArguments>
58+
59+
<!-- Do not restore CBT modules when NuGet is evaluating CBTModules.proj. -->
60+
<RestoreCBTModules Condition=" $(RestoreGraphProjectInput.Contains($(CBTModulePackageConfigPath))) ">false</RestoreCBTModules>
61+
<!--
62+
Evaluating this property loads CBT.Core.dll as a byte[] and stores the result in the AppDomain via SetData(). This is the only way we could find to load an assembly from bytes and be able to access it in a later call.
63+
Normally when assemblies are loaded with this context, other calls can't reuse the loaded assembly. Since the Assembly object is stored in the data of the AppDomain, subsequent calls can access via the GetData() method.
64+
The condition on this property also ensures that the Assembly is only loaded once per AppDomain and since property evaluation is single threaded we don't have to worry about synchronization. Another piece of this
65+
property is that the the SetData() method returns void so immediately after SetData() we call GetData() which returns the Assembly and the property evaluates to something like:
66+
"CBT.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
67+
68+
If the CBTCoreAssemblyName property has a value then we know we were able to successfully load the assembly.
69+
70+
The most complicated part of this call is how to get an object[] to pass to the ReadAllBytes() method. MSBuild coerces the arguments to a method but creating a populated object[] with one call is not possible. By calling
71+
System.IO.Directory.GetFiles(), we are returned a string[] which MSBuild coerces to an object[] to ReadAllBytes().
72+
-->
73+
<CBTCoreAssemblyName Condition=" Exists('$(CBTCoreAssemblyPath)') And '$(CBTCoreAssemblyPath.GetType().Assembly.GetType(`System.AppDomain`).GetProperty(`CurrentDomain`).GetValue(null).GetData(`CBT_CORE_ASSEMBLY`))' == '' ">$(CBTCoreAssemblyPath.GetType().Assembly.GetType('System.AppDomain').GetProperty('CurrentDomain').GetValue(null).SetData('CBT_CORE_ASSEMBLY', $(CBTCoreAssemblyPath.GetType().Assembly.GetType('System.AppDomain').GetProperty('CurrentDomain').GetValue(null).Load($(CBTCoreAssemblyPath.GetType().Assembly.GetType('System.IO.File').GetMethod('ReadAllBytes').Invoke(null, $([System.IO.Directory]::GetFiles($([System.IO.Path]::GetDirectoryName($(CBTCoreAssemblyPath))), $([System.IO.Path]::GetFileName($(CBTCoreAssemblyPath)))))))))))</CBTCoreAssemblyName>
74+
<CBTCoreAssemblyName>$(CBTCoreAssemblyPath.GetType().Assembly.GetType('System.AppDomain').GetProperty('CurrentDomain').GetValue(null).GetData('CBT_CORE_ASSEMBLY'))</CBTCoreAssemblyName>
75+
<CBTModulesRestored Condition=" '$(RestoreCBTModules)' != 'false' And '$(BuildingInsideVisualStudio)' != 'true' And '$(CBTModulesRestored)' != 'true' And '$(CBTCoreAssemblyName)' != '' ">$(CBTCoreAssemblyPath.GetType().Assembly.GetType('System.AppDomain').GetProperty('CurrentDomain').GetValue(null).GetData('CBT_CORE_ASSEMBLY').CreateInstance($(CBTModuleRestoreTaskName)).Execute($(CBTModuleImportsAfter.Split(';')), $(CBTModuleImportsBefore.Split(';')), $(CBTModuleExtensionsPath), $(CBTModulePropertiesFile), $(CBTNuGetDownloaderAssemblyPath), $(CBTNuGetDownloaderClassName), '$(CBTNuGetDownloaderArguments)', $(CBTModuleRestoreInputs.Split(';')), $(CBTModulePackageConfigPath), $(CBTModuleRestoreCommand), $(CBTModuleRestoreCommandArguments), $(MSBuildProjectFullPath), $(MSBuildBinPath)))</CBTModulesRestored>
76+
77+
</PropertyGroup>
78+
79+
<ItemGroup>
80+
<CBTParseError Condition=" '$(EnlistmentRoot)' == '' " Include="The 'EnlistmentRoot' property must be set. Please ensure it is declared in a properties file before CBT Core is imported.">
81+
<Code>CBT1000</Code>
82+
</CBTParseError>
83+
<CBTParseError Condition=" '$(CBTModulesRestored)' == 'false' " Include="Modules were not restored and the build cannot continue. Refer to other errors for more information.">
84+
<Code>CBT1001</Code>
85+
</CBTParseError>
86+
<CBTParseError Condition=" '$(CBTModulePackageConfigPath)' == '' " Include="The CBT module configuration file packages.config or CBTModules.proj was not found under $(CBTLocalPath) or $(CBTLocalPath)\CBTModules. Please add a CBT module package configuration file or set the property 'CBTModulePackageConfigPath' to your custom location.">
87+
<Code>CBT1002</Code>
88+
</CBTParseError>
89+
</ItemGroup>
90+
91+
<Import Project="$(CBTModulePropertiesFile)" Condition=" ('$(CBTModulesRestored)' == 'true' Or '$(BuildingInsideVisualStudio)' == 'true') And Exists('$(CBTModulePropertiesFile)') "/>
92+
93+
<UsingTask TaskName="RestoreModules" AssemblyFile="$(CBTCoreAssemblyPath)" />
94+
<UsingTask TaskName="WriteModuleRestoreInfo" AssemblyFile="$(CBTCoreAssemblyPath)" />
95+
96+
<Target Name="ShowCBTParseErrors" Condition=" '@(CBTParseError)' != '' ">
97+
<Error Text="%(CBTParseError.Identity)" Code="%(CBTParseError.Code)" />
98+
</Target>
99+
100+
<Target Name="RestoreCBTModules"
101+
Condition=" '$(RestoreCBTModules)' != 'false' And '$(CBTModulesRestored)' != 'true' "
102+
Inputs="$(CBTModuleRestoreInputs)"
103+
Outputs="$([MSBuild]::ValueOrDefault($(CBTModulePropertiesFile), 'null'))">
104+
105+
<RestoreModules
106+
AfterImports="$(CBTModuleImportsAfter.Split(';'))"
107+
BeforeImports="$(CBTModuleImportsBefore.Split(';'))"
108+
ExtensionsPath="$(CBTModuleExtensionsPath)"
109+
ImportsFile="$(CBTModulePropertiesFile)"
110+
MSBuildBinPath="$(MSBuildBinPath)"
111+
NuGetDownloaderAssemblyPath="$(CBTNuGetDownloaderAssemblyPath)"
112+
NuGetDownloaderClassName="$(CBTNuGetDownloaderClassName)"
113+
NuGetDownloaderArguments="$(CBTNuGetDownloaderArguments)"
114+
PackageConfig="$(CBTModulePackageConfigPath)"
115+
ProjectFullPath="$(MSBuildProjectFullPath)"
116+
RestoreCommand="$(CBTModuleRestoreCommand)"
117+
RestoreCommandArguments="$(CBTModuleRestoreCommandArguments)"
118+
/>
119+
120+
<PropertyGroup>
121+
<CBTModulesRestored Condition=" '$(CBTModulesRestored)' != 'true' ">true</CBTModulesRestored>
122+
</PropertyGroup>
123+
124+
<MSBuild Projects="$(MSBuildProjectFullPath)"
125+
Targets="CBTDesignTimeBuild"
126+
Properties="DesignTimeBuild=$(DesignTimeBuild);BuildingProject=$(BuildingProject);BuildingInsideVisualStudio=$(BuildingInsideVisualStudio);CBTModulesRestored=$(CBTModulesRestored)"
127+
Condition=" '$(CBTModulesRestored)' == 'true' And '$(BuildingInsideVisualStudio)' == 'true' "
128+
/>
129+
130+
</Target>
131+
132+
<!-- _GenerateRestoreProjectSpec is a from the nuget.targets new to NuGet 4.x. -->
133+
<Target Name="GenerateModuleRestoreInfo" AfterTargets="_GenerateRestoreProjectSpec" Condition=" '$(RestoreOutputAbsolutePath)' != '' And '$(MSBuildProjectFullPath)' == '$(CBTModulePackageConfigPath)' " >
134+
<ItemGroup>
135+
<CBTModuleRestoreInfo Remove="@(CBTModuleRestoreInfo)"/>
136+
<CBTModuleRestoreInfo Include="ProjectJsonPath">
137+
<value>$(_CurrentProjectJsonPath)</value>
138+
</CBTModuleRestoreInfo>
139+
<CBTModuleRestoreInfo Include="RestoreProjectStyle">
140+
<value>$(RestoreProjectStyle)</value>
141+
<value Condition=" '$(RestoreProjectStyle)' == '' " >$(NuGetProjectStyle)</value>
142+
</CBTModuleRestoreInfo>
143+
<CBTModuleRestoreInfo Include="RestoreOutputAbsolutePath">
144+
<value>$(RestoreOutputAbsolutePath)</value>
145+
</CBTModuleRestoreInfo>
146+
<CBTModuleRestoreInfo Include="PackageReference">
147+
<id>%(PackageReference.Identity)</id>
148+
<version>%(PackageReference.Version)</version>
149+
</CBTModuleRestoreInfo>
150+
</ItemGroup>
151+
<WriteModuleRestoreInfo File="$(CBTModuleRestoreInfoFile)" Input="@(CBTModuleRestoreInfo)" />
152+
</Target>
153+
154+
<Target Name="CBTDesignTimeBuild" DependsOnTargets="$(CBTDesignTimeBuildDependsOn)" />
155+
156+
<Import Project="$(CBTLocalBuildExtensionsPath)\After.$(MSBuildThisFile)" Condition=" '$(CBTLocalBuildExtensionsPath)' != '' And Exists('$(CBTLocalBuildExtensionsPath)\After.$(MSBuildThisFile)') " />
157+
158+
</Project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFramework>net46</TargetFramework>
5+
</PropertyGroup>
6+
<!--
7+
*******************************************************************************************************************
8+
This file contains the CBT modules that you want to use. Modules are standard NuGet packages that apply to the
9+
whole project tree rather than on a per-project basis. Modules provide extensions to your build in a centralized
10+
way and act as a replacement of having to check-in all of the build logic.
11+
12+
Modules include build extensions such as:
13+
14+
1. Analyzing source code and/or build output
15+
2. Assembly versioning
16+
3. Policy enforcement
17+
4. Strong-name signing of build output
18+
19+
To find more modules, use "NuGet.exe list CBT.*" or browse a list at http://commonbuildtoolset.github.io
20+
*******************************************************************************************************************
21+
-->
22+
23+
<ItemGroup>
24+
<!--
25+
*******************************************************************************************************************
26+
CBT.Traversal module provides the build logic to have a dirs.proj which defines the projects you want built in a
27+
hosted build environment. Use this module if you want more control over your official build output and are willing
28+
to move away from Visual Studio solution files.
29+
*******************************************************************************************************************
30+
-->
31+
<PackageReference Include="CBT.Traversal" Version="2.0.53" />
32+
33+
<!--
34+
*******************************************************************************************************************
35+
CBT.NuGet module provides NuGet package restore from the command-line prior to build. This allows users to not
36+
have to restore before building a project tree. This is mostly useful for hosted builds which run from a command-
37+
line environment rather than Visual Studio.
38+
*******************************************************************************************************************
39+
-->
40+
<PackageReference Include="CBT.NuGet" Version="2.2.2" />
41+
42+
<!--
43+
*******************************************************************************************************************
44+
CBT.DotNetFx provides the .NET Framework reference assemblies so that users do not have to have them installed to
45+
build your projects. When using this module, be sure to include ALL of the versions of the target frameworks that
46+
your projects use. For example, if your projects target .NET 4.5 and .NET 4.6, you'll need to include both of the
47+
corresponding modules.
48+
49+
By default build packages are disabled when added to the cbtmodules project.
50+
To use any build package globally it must be enabled for the code base.
51+
Do this by setting Enable#NuGetPackageID# where the . is replaced with _.
52+
Example add this property to your Directory.Build.props for the CBT.DotNetFx-net46 package.
53+
<EnableCBT_DotNetFx-net46>true</EnableCBT_DotNetFx-net46>
54+
*******************************************************************************************************************
55+
-->
56+
<PackageReference Include="CBT.DotNetFx-net46" Version="1.0.0-beta01" />
57+
58+
59+
</ItemGroup>
60+
</Project>

0 commit comments

Comments
 (0)