Skip to content

Commit 22536a7

Browse files
Robert Va?anRobert Va?an
Robert Va?an
authored and
Robert Va?an
committed
Imported sample Fody addin
0 parents  commit 22536a7

23 files changed

+767
-0
lines changed

.hgignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
syntax: glob
2+
bin
3+
obj
4+
packages
5+
NuGetBuild
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{E97E649F-B703-47E3-B18A-0871D3498742}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>AssemblyToProcess</RootNamespace>
11+
<AssemblyName>AssemblyToProcess</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Core" />
35+
<Reference Include="System.Xml.Linq" />
36+
<Reference Include="System.Data.DataSetExtensions" />
37+
<Reference Include="Microsoft.CSharp" />
38+
<Reference Include="System.Data" />
39+
<Reference Include="System.Xml" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<Compile Include="Class1.cs" />
43+
</ItemGroup>
44+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
45+
</Project>

AssemblyToProcess/Class1.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+

2+
namespace AssemblyToProcess
3+
{
4+
class Class1
5+
{
6+
}
7+
}

BasicFodyAddin.sln

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicFodyAddin", "BasicFodyAddin\BasicFodyAddin.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{5A86453B-96FB-4B6E-A283-225BB9F753D3}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nuget", "NuGet\Nuget.csproj", "{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}"
9+
ProjectSection(ProjectDependencies) = postProject
10+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD} = {C3578A7B-09A6-4444-9383-0DEAFA4958BD}
11+
EndProjectSection
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyToProcess", "AssemblyToProcess\AssemblyToProcess.csproj", "{E97E649F-B703-47E3-B18A-0871D3498742}"
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|Any CPU = Debug|Any CPU
18+
Debug|x86 = Debug|x86
19+
Release|Any CPU = Release|Any CPU
20+
Release|x86 = Release|x86
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|x86.ActiveCfg = Debug|Any CPU
26+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|x86.ActiveCfg = Release|Any CPU
29+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|x86.ActiveCfg = Debug|Any CPU
32+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|x86.ActiveCfg = Release|Any CPU
35+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Debug|x86.ActiveCfg = Debug|Any CPU
38+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}.Release|x86.ActiveCfg = Release|Any CPU
41+
{E97E649F-B703-47E3-B18A-0871D3498742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{E97E649F-B703-47E3-B18A-0871D3498742}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{E97E649F-B703-47E3-B18A-0871D3498742}.Debug|x86.ActiveCfg = Debug|Any CPU
44+
{E97E649F-B703-47E3-B18A-0871D3498742}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{E97E649F-B703-47E3-B18A-0871D3498742}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{E97E649F-B703-47E3-B18A-0871D3498742}.Release|x86.ActiveCfg = Release|Any CPU
47+
EndGlobalSection
48+
GlobalSection(SolutionProperties) = preSolution
49+
HideSolutionNode = FALSE
50+
EndGlobalSection
51+
EndGlobal

BasicFodyAddin/AssemblyInfo.cs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyTitle("SampleFodyAddin")]
4+
[assembly: AssemblyProduct("SampleFodyAddin")]
5+
[assembly: AssemblyVersion("0.3.2")]
6+
[assembly: AssemblyFileVersion("0.3.2")]

BasicFodyAddin/BasicFodyAddin.csproj

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{C3578A7B-09A6-4444-9383-0DEAFA4958BD}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>BasicFodyAddin.Fody</RootNamespace>
12+
<AssemblyName>BasicFodyAddin.Fody</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
<DocumentationFile>
25+
</DocumentationFile>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup>
36+
<SignAssembly>false</SignAssembly>
37+
</PropertyGroup>
38+
<PropertyGroup>
39+
<AssemblyOriginatorKeyFile>..\key.snk</AssemblyOriginatorKeyFile>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="Mono.Cecil">
43+
<HintPath>..\packages\FodyCecil.1.24.0-beta2\lib\net40\Mono.Cecil.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Mono.Cecil.Mdb">
46+
<HintPath>..\packages\FodyCecil.1.24.0-beta2\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Mono.Cecil.Pdb">
49+
<HintPath>..\packages\FodyCecil.1.24.0-beta2\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Mono.Cecil.Rocks">
52+
<HintPath>..\packages\FodyCecil.1.24.0-beta2\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
53+
</Reference>
54+
<Reference Include="System" />
55+
<Reference Include="System.Core" />
56+
<Reference Include="System.Xml" />
57+
<Reference Include="System.Xml.Linq" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<Compile Include="AssemblyInfo.cs" />
61+
<Compile Include="ModuleWeaver.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<None Include="packages.config" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
</Project>

BasicFodyAddin/ModuleWeaver.cs

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Linq;
3+
using Mono.Cecil;
4+
using Mono.Cecil.Rocks;
5+
using Mono.Cecil.Cil;
6+
7+
public class ModuleWeaver
8+
{
9+
// Will log an informational message to MSBuild
10+
public Action<string> LogInfo { get; set; }
11+
12+
// An instance of Mono.Cecil.ModuleDefinition for processing
13+
public ModuleDefinition ModuleDefinition { get; set; }
14+
15+
TypeSystem typeSystem;
16+
17+
// Init logging delegates to make testing easier
18+
public ModuleWeaver()
19+
{
20+
LogInfo = m => { };
21+
}
22+
23+
public void Execute()
24+
{
25+
typeSystem = ModuleDefinition.TypeSystem;
26+
var newType = new TypeDefinition(null, "Hello", TypeAttributes.Public, typeSystem.Object);
27+
28+
AddConstructor(newType);
29+
30+
AddHelloWorld(newType);
31+
32+
ModuleDefinition.Types.Add(newType);
33+
LogInfo("Added type 'Hello' with method 'World'.");
34+
}
35+
36+
void AddConstructor(TypeDefinition newType)
37+
{
38+
var method = new MethodDefinition(".ctor", MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, typeSystem.Void);
39+
var objectConstructor = ModuleDefinition.Import(typeSystem.Object.Resolve().GetConstructors().First());
40+
var processor = method.Body.GetILProcessor();
41+
processor.Emit(OpCodes.Ldarg_0);
42+
processor.Emit(OpCodes.Call, objectConstructor);
43+
processor.Emit(OpCodes.Ret);
44+
newType.Methods.Add(method);
45+
}
46+
47+
void AddHelloWorld( TypeDefinition newType)
48+
{
49+
var method = new MethodDefinition("World", MethodAttributes.Public, typeSystem.String);
50+
var processor = method.Body.GetILProcessor();
51+
processor.Emit(OpCodes.Ldstr, "Hello World");
52+
processor.Emit(OpCodes.Ret);
53+
newType.Methods.Add(method);
54+
}
55+
}

BasicFodyAddin/packages.config

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="FodyCecil" version="1.24.0-beta2" targetFramework="net40" developmentDependency="true" />
4+
</packages>

Content/ToBeDeleted.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


Icons/noun_project_16919.svg

+27
Loading

Icons/package_icon.png

2.27 KB
Loading

NuGet/BasicFodyAddin.nuspec

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3+
<metadata minClientVersion="2.8">
4+
<id>BasicFodyAddin.Fody</id>
5+
<version>$version$</version>
6+
<title>BasicFodyAddin.Fody</title>
7+
<authors>Simon Cropp</authors>
8+
<owners>Simon Cropp</owners>
9+
<developmentDependency>true</developmentDependency>
10+
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
11+
<projectUrl>http://github.com/Fody/BasicFodyAddin</projectUrl>
12+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
13+
<iconUrl>https://raw.github.com/Fody/BasicFodyAddin/master/Icons/package_icon.png</iconUrl>
14+
<description>A sample Fody add-in.</description>
15+
<summary />
16+
<language>en-AU</language>
17+
<tags>ILWeaving, Fody, Cecil</tags>
18+
<dependencies>
19+
<dependency id="Fody"/>
20+
</dependencies>
21+
</metadata>
22+
</package>

NuGet/Fody_ToBeDeleted.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


NuGet/Nuget.csproj

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{63786CE5-D899-43DF-AD4E-C2CA3BAC3FC2}</ProjectGuid>
7+
8+
</PropertyGroup>
9+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
10+
<ConfigurationName>Debug</ConfigurationName>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
13+
<ConfigurationName>Release</ConfigurationName>
14+
</PropertyGroup>
15+
<ItemGroup>
16+
<None Include="BasicFodyAddin.nuspec" />
17+
<None Include="install.ps1" />
18+
<None Include="packages.config" />
19+
<None Include="uninstall.ps1" />
20+
<Content Include="Fody_ToBeDeleted.txt" />
21+
</ItemGroup>
22+
<Target Name="Clean">
23+
<RemoveDir Directories="$(SolutionDir)NuGetBuild" />
24+
</Target>
25+
<Target Name="Build" DependsOnTargets="NuGetBuild" />
26+
<Target Name="ReBuild" DependsOnTargets="NuGetBuild" />
27+
<Target Name="NuGetBuild" DependsOnTargets="Clean">
28+
<MakeDir Directories="$(SolutionDir)NuGetBuild" />
29+
<Copy SourceFiles="$(SolutionDir)NuGet\BasicFodyAddin.nuspec" DestinationFolder="$(SolutionDir)NuGetBuild" />
30+
<Copy SourceFiles="$(SolutionDir)BasicFodyAddin\bin\$(ConfigurationName)\BasicFodyAddin.Fody.dll" DestinationFolder="$(SolutionDir)NuGetBuild" />
31+
<Copy SourceFiles="$(SolutionDir)NuGet\Fody_ToBeDeleted.txt" DestinationFolder="$(SolutionDir)NuGetBuild\Content" />
32+
<Copy SourceFiles="$(ProjectDir)install.ps1" DestinationFolder="$(SolutionDir)NuGetBuild\Tools" />
33+
<Copy SourceFiles="$(ProjectDir)uninstall.ps1" DestinationFolder="$(SolutionDir)NuGetBuild\Tools" />
34+
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(SolutionDir)NuGetBuild" MetadataAssembly="$(SolutionDir)BasicFodyAddin\bin\$(ConfigurationName)\BasicFodyAddin.Fody.dll" />
35+
</Target>
36+
<ItemGroup>
37+
<ProjectReference Include="..\BasicFodyAddin\BasicFodyAddin.csproj">
38+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
39+
<Project>{C3578A7B-09A6-4444-9383-0DEAFA4958BD}</Project>
40+
<Name>BasicFodyAddin</Name>
41+
</ProjectReference>
42+
</ItemGroup>
43+
<Import Project="..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets" Condition="Exists('..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets')" />
44+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
45+
<PropertyGroup>
46+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
47+
</PropertyGroup>
48+
<Error Condition="!Exists('..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets'))" />
49+
</Target>
50+
</Project>

0 commit comments

Comments
 (0)