Skip to content

Commit 642b4c2

Browse files
Robert Va?anRobert Va?an
Robert Va?an
authored and
Robert Va?an
committed
Renamed to AutoDependencyProperty
1 parent d56c572 commit 642b4c2

13 files changed

+50
-40
lines changed

AssemblyToProcess/AssemblyToProcess.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
<Compile Include="Class1.cs" />
4646
</ItemGroup>
4747
<ItemGroup>
48-
<ProjectReference Include="..\FodyDependencyPropertyMarker\FodyDependencyPropertyMarker.csproj">
48+
<ProjectReference Include="..\AutoDependencyPropertyMarker\AutoDependencyPropertyMarker.csproj">
4949
<Project>{415fd599-6e6d-411f-80f7-70991fd5a0a2}</Project>
50-
<Name>FodyDependencyPropertyMarker</Name>
50+
<Name>AutoDependencyPropertyMarker</Name>
5151
</ProjectReference>
5252
</ItemGroup>
5353
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

AssemblyToProcess/Class1.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using FodyDependencyPropertyMarker;
1+
using AutoDependencyPropertyMarker;
22
using System;
33
using System.Windows;
44

55
namespace AssemblyToProcess
66
{
77
public class Class1 : DependencyObject
88
{
9-
[DependencyProperty(Options = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)]
9+
[AutoDependencyProperty(Options = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)]
1010
public string MyProp { get; set; }
11-
[DependencyProperty(Options = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)]
11+
[AutoDependencyProperty(Options = FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)]
1212
public int IntProp { get; set; }
1313
}
1414
}

FodyDependencyProperty.sln AutoDependencyProperty.Fody.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
44
VisualStudioVersion = 12.0.30110.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FodyDependencyProperty", "FodyDependencyProperty\FodyDependencyProperty.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoDependencyProperty.Fody", "AutoDependencyProperty.Fody\AutoDependencyProperty.Fody.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{5A86453B-96FB-4B6E-A283-225BB9F753D3}"
99
EndProject
@@ -14,7 +14,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nuget", "NuGet\Nuget.csproj
1414
EndProject
1515
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyToProcess", "AssemblyToProcess\AssemblyToProcess.csproj", "{E97E649F-B703-47E3-B18A-0871D3498742}"
1616
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FodyDependencyPropertyMarker", "FodyDependencyPropertyMarker\FodyDependencyPropertyMarker.csproj", "{415FD599-6E6D-411F-80F7-70991FD5A0A2}"
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoDependencyPropertyMarker", "AutoDependencyPropertyMarker\AutoDependencyPropertyMarker.csproj", "{415FD599-6E6D-411F-80F7-70991FD5A0A2}"
1818
EndProject
1919
Global
2020
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Reflection;
22

3-
[assembly: AssemblyTitle("FodyDependencyProperty")]
3+
[assembly: AssemblyTitle("AutoDependencyProperty.Fody")]
44
[assembly: AssemblyDescription("Fody plugin that converts automatic C# property into WPF DependencyProperty during build")]
5-
[assembly: AssemblyProduct("FodyDependencyProperty")]
5+
[assembly: AssemblyProduct("AutoDependencyProperty.Fody")]
66
[assembly: AssemblyCompany("Robert Važan")]
77
[assembly: AssemblyCopyright("Copyright © 2014 Robert Važan")]
8-
[assembly: AssemblyVersion("1.1.6.0")]
8+
[assembly: AssemblyVersion("1.2.1.0")]

FodyDependencyProperty/FodyDependencyProperty.csproj AutoDependencyProperty.Fody/AutoDependencyProperty.Fody.csproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<ProjectGuid>{C3578A7B-09A6-4444-9383-0DEAFA4958BD}</ProjectGuid>
99
<OutputType>Library</OutputType>
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>FodyDependencyProperty</RootNamespace>
12-
<AssemblyName>FodyDependencyProperty.Fody</AssemblyName>
11+
<RootNamespace>AutoDependencyProperty</RootNamespace>
12+
<AssemblyName>AutoDependencyProperty.Fody</AssemblyName>
1313
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
</PropertyGroup>
@@ -51,6 +51,8 @@
5151
<Reference Include="Mono.Cecil.Rocks">
5252
<HintPath>..\packages\FodyCecil.1.24.0-beta2\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
5353
</Reference>
54+
<Reference Include="PresentationCore" />
55+
<Reference Include="PresentationFramework" />
5456
<Reference Include="System" />
5557
<Reference Include="System.Core" />
5658
<Reference Include="System.Xml" />

FodyDependencyProperty/ModuleWeaver.cs AutoDependencyProperty.Fody/ModuleWeaver.cs

+16-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ModuleWeaver
1212

1313
public void Execute()
1414
{
15-
var markerDll = Check(() => ModuleDefinition.AssemblyReferences.SingleOrDefault(a => a.Name.ToLowerInvariant() == "FodyDependencyPropertyMarker".ToLowerInvariant()), "find FodyDependencyPropertyMarker reference");
15+
var markerDll = Check(() => ModuleDefinition.AssemblyReferences.SingleOrDefault(a => a.Name.ToLowerInvariant() == "AutoDependencyPropertyMarker".ToLowerInvariant()), "find AutoDependencyPropertyMarker reference");
1616
if (markerDll == null)
1717
return;
1818
var windowsBase = CheckAssembly("WindowsBase");
@@ -27,11 +27,6 @@ public void Execute()
2727
var registerMeta = CheckImport(() => depProperty.Methods.Single(m => m.Name == "Register" && m.Parameters.Count == 4), "Register");
2828
var presentationDllRef = Check(() => ModuleDefinition.AssemblyReferences.SingleOrDefault(a => a.Name.ToLowerInvariant() == "PresentationFramework".ToLowerInvariant()), "check for PresentationFramework reference");
2929
MethodReference metadataCtor = null;
30-
if (presentationDllRef != null)
31-
{
32-
var presentationDll = CheckAssembly("PresentationFramework");
33-
metadataCtor = CheckImport(() => presentationDll.GetType("System.Windows.FrameworkPropertyMetadata").GetConstructors().Single(c => c.Parameters.Count == 2 && c.Parameters[1].ParameterType.Name == "FrameworkPropertyMetadataOptions"), "FrameworkPropertyMetadata constructor");
34-
}
3530
foreach (var type in ModuleDefinition.Types)
3631
if (!type.IsSpecialName && type.GenericParameters.Count == 0 && Inherits(type, "System.Windows.DependencyObject"))
3732
{
@@ -41,7 +36,7 @@ public void Execute()
4136
if (!property.IsSpecialName && property.HasThis && property.GetMethod != null && property.SetMethod != null && property.GetMethod.IsPublic && property.SetMethod.IsPublic)
4237
{
4338
var attribute = property.CustomAttributes.Concat(type.CustomAttributes).FirstOrDefault(
44-
a => a.AttributeType.FullName == "FodyDependencyPropertyMarker.DependencyPropertyAttribute");
39+
a => a.AttributeType.FullName == "AutoDependencyPropertyMarker.AutoDependencyPropertyAttribute");
4540
if (attribute == null)
4641
continue;
4742
if (type.Fields.Any(f => f.Name == property.Name + "Property"))
@@ -67,10 +62,23 @@ public void Execute()
6762
instructions.Add(Instruction.Create(OpCodes.Call, registerSimple));
6863
else
6964
{
65+
if (metadataCtor == null)
66+
{
67+
if (presentationDllRef == null)
68+
{
69+
metadataCtor = Check(() => ModuleDefinition.Import(typeof(FrameworkPropertyMetadata).GetConstructor(new[] { typeof(object), typeof(FrameworkPropertyMetadataOptions) })), "directly import FrameworkPropertyMetadata constructor");
70+
}
71+
else
72+
{
73+
var presentationDll = CheckAssembly("PresentationFramework");
74+
metadataCtor = CheckImport(() => presentationDll.GetType("System.Windows.FrameworkPropertyMetadata").GetConstructors().Single(c => c.Parameters.Count == 2 && c.Parameters[1].ParameterType.Name == "FrameworkPropertyMetadataOptions"), "FrameworkPropertyMetadata constructor");
75+
}
76+
}
7077
if (!property.PropertyType.IsValueType)
7178
instructions.Add(Instruction.Create(OpCodes.Ldnull));
7279
else
7380
{
81+
cctor.Body.InitLocals = true;
7482
var constVar = new VariableDefinition(property.PropertyType);
7583
cctor.Body.Variables.Add(constVar);
7684
instructions.Add(Instruction.Create(OpCodes.Ldloca_S, constVar));
@@ -107,7 +115,7 @@ public void Execute()
107115
instructions.Reverse();
108116
foreach (var instruction in instructions)
109117
cctor.Body.Instructions.Insert(0, instruction);
110-
foreach (var attribute in type.CustomAttributes.Where(a => a.AttributeType.FullName == "FodyDependencyPropertyMarker.DependencyPropertyAttribute").ToList())
118+
foreach (var attribute in type.CustomAttributes.Where(a => a.AttributeType.FullName == "AutoDependencyPropertyMarker.AutoDependencyPropertyAttribute").ToList())
111119
type.CustomAttributes.Remove(attribute);
112120
}
113121
ModuleDefinition.AssemblyReferences.Remove(markerDll);

FodyDependencyPropertyMarker/DependencyPropertyAttribute.cs AutoDependencyPropertyMarker/AutoDependencyPropertyAttribute.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using System.Threading.Tasks;
66
using System.Windows;
77

8-
namespace FodyDependencyPropertyMarker
8+
namespace AutoDependencyPropertyMarker
99
{
1010
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
11-
public class DependencyPropertyAttribute : Attribute
11+
public class AutoDependencyPropertyAttribute : Attribute
1212
{
1313
public FrameworkPropertyMetadataOptions Options { get; set; }
1414
}

FodyDependencyPropertyMarker/FodyDependencyPropertyMarker.csproj AutoDependencyPropertyMarker/AutoDependencyPropertyMarker.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{415FD599-6E6D-411F-80F7-70991FD5A0A2}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>FodyDependencyPropertyMarker</RootNamespace>
11-
<AssemblyName>FodyDependencyPropertyMarker</AssemblyName>
10+
<RootNamespace>AutoDependencyPropertyMarker</RootNamespace>
11+
<AssemblyName>AutoDependencyPropertyMarker</AssemblyName>
1212
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
@@ -41,7 +41,7 @@
4141
<Reference Include="System.Xml" />
4242
</ItemGroup>
4343
<ItemGroup>
44-
<Compile Include="DependencyPropertyAttribute.cs" />
44+
<Compile Include="AutoDependencyPropertyAttribute.cs" />
4545
<Compile Include="Properties\AssemblyInfo.cs" />
4646
</ItemGroup>
4747
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

FodyDependencyPropertyMarker/Properties/AssemblyInfo.cs AutoDependencyPropertyMarker/Properties/AssemblyInfo.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("FodyDependencyPropertyMarker")]
9-
[assembly: AssemblyDescription("Attribute for FodyDependencyProperty Fody plugin")]
8+
[assembly: AssemblyTitle("AutoDependencyPropertyMarker")]
9+
[assembly: AssemblyDescription("Attribute for AutoDependencyProperty.Fody plugin")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("Robert Važan")]
12-
[assembly: AssemblyProduct("FodyDependencyPropertyMarker")]
12+
[assembly: AssemblyProduct("AutoDependencyPropertyMarker")]
1313
[assembly: AssemblyCopyright("Copyright © 2014 Robert Važan")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
@@ -32,4 +32,4 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.6.0")]
35+
[assembly: AssemblyVersion("1.2.1.0")]

NuGet/FodyDependencyProperty.nuspec NuGet/AutoDependencyProperty.Fody.nuspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata minClientVersion="2.8">
4-
<id>FodyDependencyProperty.Fody</id>
4+
<id>AutoDependencyProperty.Fody</id>
55
<version>$version$</version>
6-
<title>FodyDependencyProperty</title>
6+
<title>AutoDependencyProperty.Fody</title>
77
<authors>Robert Važan</authors>
88
<owners>Robert Važan</owners>
99
<developmentDependency>true</developmentDependency>

NuGet/Nuget.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ConfigurationName>Release</ConfigurationName>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<None Include="FodyDependencyProperty.nuspec">
15+
<None Include="AutoDependencyProperty.Fody.nuspec">
1616
<SubType>Designer</SubType>
1717
</None>
1818
<None Include="install.ps1" />
@@ -29,18 +29,18 @@
2929
<Target Name="NuGetBuild" DependsOnTargets="Clean">
3030
<MakeDir Directories="$(SolutionDir)NuGetBuild" />
3131
<MakeDir Directories="$(SolutionDir)NuGetBuild\lib\net40" />
32-
<Copy SourceFiles="$(SolutionDir)NuGet\FodyDependencyProperty.nuspec" DestinationFolder="$(SolutionDir)NuGetBuild" />
33-
<Copy SourceFiles="$(SolutionDir)FodyDependencyProperty\bin\$(ConfigurationName)\FodyDependencyProperty.Fody.dll" DestinationFolder="$(SolutionDir)NuGetBuild" />
34-
<Copy SourceFiles="$(SolutionDir)FodyDependencyPropertyMarker\bin\$(ConfigurationName)\FodyDependencyPropertyMarker.dll" DestinationFolder="$(SolutionDir)NuGetBuild\lib\net40" />
32+
<Copy SourceFiles="$(SolutionDir)NuGet\AutoDependencyProperty.Fody.nuspec" DestinationFolder="$(SolutionDir)NuGetBuild" />
33+
<Copy SourceFiles="$(SolutionDir)AutoDependencyProperty.Fody\bin\$(ConfigurationName)\AutoDependencyProperty.Fody.dll" DestinationFolder="$(SolutionDir)NuGetBuild" />
34+
<Copy SourceFiles="$(SolutionDir)AutoDependencyPropertyMarker\bin\$(ConfigurationName)\AutoDependencyPropertyMarker.dll" DestinationFolder="$(SolutionDir)NuGetBuild\lib\net40" />
3535
<Copy SourceFiles="$(ProjectDir)install.ps1" DestinationFolder="$(SolutionDir)NuGetBuild\Tools" />
3636
<Copy SourceFiles="$(ProjectDir)uninstall.ps1" DestinationFolder="$(SolutionDir)NuGetBuild\Tools" />
37-
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(SolutionDir)NuGetBuild" MetadataAssembly="$(SolutionDir)FodyDependencyProperty\bin\$(ConfigurationName)\FodyDependencyProperty.Fody.dll" />
37+
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(SolutionDir)NuGetBuild" MetadataAssembly="$(SolutionDir)AutoDependencyProperty.Fody\bin\$(ConfigurationName)\AutoDependencyProperty.Fody.dll" />
3838
</Target>
3939
<ItemGroup>
40-
<ProjectReference Include="..\FodyDependencyProperty\FodyDependencyProperty.csproj">
40+
<ProjectReference Include="..\AutoDependencyProperty.Fody\AutoDependencyProperty.Fody.csproj">
4141
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
4242
<Project>{C3578A7B-09A6-4444-9383-0DEAFA4958BD}</Project>
43-
<Name>FodyDependencyProperty</Name>
43+
<Name>AutoDependencyProperty.Fody</Name>
4444
</ProjectReference>
4545
</ItemGroup>
4646
<Import Project="..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets" Condition="Exists('..\packages\PepitaPackage.1.20.0.0\build\PepitaPackage.targets')" />

Tests/Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
<Compile Include="WeaverTests.cs" />
6464
</ItemGroup>
6565
<ItemGroup>
66-
<ProjectReference Include="..\FodyDependencyProperty\FodyDependencyProperty.csproj">
66+
<ProjectReference Include="..\AutoDependencyProperty.Fody\AutoDependencyProperty.Fody.csproj">
6767
<Project>{C3578A7B-09A6-4444-9383-0DEAFA4958BD}</Project>
68-
<Name>FodyDependencyProperty</Name>
68+
<Name>AutoDependencyProperty.Fody</Name>
6969
</ProjectReference>
7070
<ProjectReference Include="..\AssemblyToProcess\AssemblyToProcess.csproj">
7171
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>

0 commit comments

Comments
 (0)