本文整理汇总了C#中ModuleWeaver类的典型用法代码示例。如果您正苦于以下问题:C# ModuleWeaver类的具体用法?C# ModuleWeaver怎么用?C# ModuleWeaver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleWeaver类属于命名空间,在下文中一共展示了ModuleWeaver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ModuleWeaverOrdinalTests
public ModuleWeaverOrdinalTests()
{
beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "3.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
var weavingTask = new ModuleWeaver
{
Config = XElement.Parse(@"<Caseless StringComparison="" ordinal ""/>"),
ModuleDefinition = moduleDefinition,
};
weavingTask.Execute();
moduleDefinition.Assembly.Name.Name += "ForOrdinal";
moduleDefinition.Write(afterAssemblyPath);
var assembly = Assembly.LoadFrom(afterAssemblyPath);
var type = assembly.GetType("TargetClass", true);
targetClass = Activator.CreateInstance(type);
}
开发者ID:Fody,项目名称:Caseless,代码行数:27,代码来源:ModuleWeaverOrdinalTests.cs
示例2: IntegrationTests
public IntegrationTests()
{
beforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var assemblyResolver = new MockAssemblyResolver
{
Directory = Path.GetDirectoryName(beforeAssemblyPath)
};
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
{
AssemblyResolver = assemblyResolver
});
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
assembly = Assembly.LoadFile(afterAssemblyPath);
}
开发者ID:GeertvanHorrik,项目名称:Equals,代码行数:30,代码来源:IntegrationTests.cs
示例3: True
public void True()
{
var xElement = XElement.Parse("<PropertyChanged InjectOnPropertyNameChanged='true'/>");
var moduleWeaver = new ModuleWeaver {Config = xElement};
moduleWeaver.ResolveOnPropertyNameChangedConfig();
Assert.IsTrue(moduleWeaver.InjectOnPropertyNameChanged);
}
开发者ID:jbruening,项目名称:PropertyChanged,代码行数:7,代码来源:OnPropertyNameChangedConfigTests.cs
示例4: ModuleWeaverOperandTests
public ModuleWeaverOperandTests()
{
var beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
var afterAssemblyPath = typeof(ModuleWeaverOperandTests).Name + ".dll";
var moduleDefinition = ModuleDefinition.ReadModule(beforeAssemblyPath);
AddConditionalBranchLong(moduleDefinition, moduleDefinition.Types.Single(t => t.Name == "TargetClass"));
// Offset assignment happens on write
// Having offsets assigned prior to weaving makes tracking down bugs easier
moduleDefinition.Write(afterAssemblyPath);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
};
weavingTask.Execute();
moduleDefinition.Assembly.Name.Name += "ForOperand";
moduleDefinition.Write(afterAssemblyPath);
var assembly = Assembly.LoadFrom(afterAssemblyPath);
var type = assembly.GetType("TargetClass", true);
targetClass = Activator.CreateInstance(type);
}
开发者ID:Fody,项目名称:Caseless,代码行数:27,代码来源:ModuleWeaverOperandTests.cs
示例5: WeaveAssembly
protected static string WeaveAssembly(Type assemblyType)
{
var normalizedPath = assemblyType.Assembly.CodeBase.Replace(@"file:///", string.Empty);
var weaver = new ModuleWeaver();
return WeavedAssemblyPath = weaver.WeaveToShadowFile(normalizedPath);
}
开发者ID:swestner,项目名称:MethodBoundaryAspect.Fody,代码行数:7,代码来源:MethodBoundaryAspectTestBase.cs
示例6: VerifyRefError
public void VerifyRefError()
{
var errors = new List<string>();
var assemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyToProcessWithErrors\bin\Debug\AssemblyToProcessWithErrors.dll"));
#if (!DEBUG)
assemblyPath = assemblyPath.Replace("Debug", "Release");
#endif
var moduleDefinition = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters
{
//SymbolStream = symbolStream,
ReadSymbols = true
});
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
LogErrorPoint = (s, p) => errors.Add(s)
};
weavingTask.Execute();
Assert.Contains("Method 'ClassUsingOutParam.Method' uses member 'ClassWithField.Member' as a 'ref' or 'out' parameter. This is not supported by Fielder. Please convert this field to a property manually.", errors);
Assert.Contains("Method 'ClassUsingRefParam.Method' uses member 'ClassWithField.Member' as a 'ref' or 'out' parameter. This is not supported by Fielder. Please convert this field to a property manually.", errors);
Assert.AreEqual(2, errors.Count);
}
开发者ID:Fody,项目名称:Fielder,代码行数:25,代码来源:CheckForErrors.cs
示例7: Simple
public void Simple()
{
var beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\AssemblyWithExcludes\bin\Debug\AssemblyWithExcludes.dll"));
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
var afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
ExcludeNamespaces = new List<string> { "ExcludeNamespace"}
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
var assembly = Assembly.LoadFile(afterAssemblyPath);
var excludeType = assembly.GetType("ExcludeNamespace.ExcludeClass");
Assert.IsFalse(excludeType.GetMethod("Method").IsVirtual);
var includeType = assembly.GetType("IncludeNamespace.IncludeClass");
Assert.IsTrue(includeType.GetMethod("Method").IsVirtual);
var inNamespaceButWithAttributeType = assembly.GetType("IncludeNamespace.InNamespaceButWithAttributeClass");
Assert.IsFalse(inNamespaceButWithAttributeType.GetMethod("Method").IsVirtual);
var notInNamespaceButWithAttributeType = assembly.GetType("ExcludeNamespace.NotInNamespaceButWithAttributeClass");
Assert.IsFalse(notInNamespaceButWithAttributeType.GetMethod("Method").IsVirtual);
#if(DEBUG)
Verifier.Verify(beforeAssemblyPath, afterAssemblyPath);
#endif
}
开发者ID:Fody,项目名称:Virtuosity,代码行数:35,代码来源:AssemblyWithExcludesTest.cs
示例8: AssemblyWeaver
static AssemblyWeaver()
{
BeforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
BeforeAssemblyPathSymbols = Path.ChangeExtension(BeforeAssemblyPath, "pdb");
#if (!DEBUG)
BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
BeforeAssemblyPathSymbols = BeforeAssemblyPathSymbols.Replace("Debug", "Release");
#endif
AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
AfterAssemblyPathSymbols = Path.ChangeExtension(AfterAssemblyPath, "pdb");
File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
File.Copy(BeforeAssemblyPathSymbols, AfterAssemblyPathSymbols, true);
var assemblyResolver = new MockAssemblyResolver();
var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, new ReaderParameters { ReadSymbols = true });
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
LogError = LogError,
LogInfo = LogInfo,
DefineConstants = new[] { "DEBUG" }, // Always testing the debug weaver
};
weavingTask.Execute();
moduleDefinition.Write(AfterAssemblyPath, new WriterParameters { WriteSymbols = true });
Assembly = Assembly.LoadFile(AfterAssemblyPath);
}
开发者ID:RobertGiesecke,项目名称:Visualize,代码行数:32,代码来源:AssemblyWeaver.cs
示例9: ProcessAssemblyBaseTest
protected ProcessAssemblyBaseTest( string relativePath )
{
BeforeAssemblyPath = Path.GetFullPath( relativePath );
#if !DEBUG
BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
#endif
AfterAssemblyPath = BeforeAssemblyPath.Replace( ".dll", "2.dll" );
File.Copy( BeforeAssemblyPath, AfterAssemblyPath, true );
var moduleDefinition = ModuleDefinition.ReadModule( AfterAssemblyPath );
var currentDirectory = AssemblyLocation.CurrentDirectory();
PersistentInfo = PersistentInfo.LoadFromPath( currentDirectory );
StandardInfo = new StandardInfo( PersistentInfo, moduleDefinition );
var moduleWeaver = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AddinDirectoryPath = currentDirectory,
SolutionDirectoryPath = currentDirectory,
AssemblyFilePath = AfterAssemblyPath,
};
moduleWeaver.Execute();
moduleDefinition.Write( AfterAssemblyPath );
moduleWeaver.AfterWeaving();
AfterAssembly = Assembly.LoadFile( AfterAssemblyPath );
}
开发者ID:ismailfatih,项目名称:CK-Stamp,代码行数:30,代码来源:ProcessAssemblyBaseTest.cs
示例10: False
public void False()
{
var xElement = XElement.Parse("<PropertyChanged InjectOnPropertyNameChanging='false'/>");
var moduleWeaver = new ModuleWeaver { Config = xElement };
moduleWeaver.ResolveOnPropertyNameChangingConfig();
Assert.IsFalse(moduleWeaver.InjectOnPropertyNameChanging);
}
开发者ID:mdabbagh88,项目名称:PropertyChanging,代码行数:7,代码来源:OnPropertyNameChangingConfigTests.cs
示例11: AssemblyWeaver
public AssemblyWeaver(string assemblyPath, List<string> referenceAssemblyPaths = null)
{
if (referenceAssemblyPaths == null)
{
referenceAssemblyPaths = new List<string>();
}
assemblyPath = FixAssemblyPath(assemblyPath);
var newAssembly = assemblyPath.Replace(".dll", "2.dll");
File.Copy(assemblyPath, newAssembly, true);
var assemblyResolver = new MockAssemblyResolver();
foreach (var referenceAssemblyPath in referenceAssemblyPaths)
{
var directoryName = Path.GetDirectoryName(referenceAssemblyPath);
assemblyResolver.AddSearchDirectory(directoryName);
}
var readerParameters = new ReaderParameters
{
AssemblyResolver = assemblyResolver
};
var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
LogError = LogError,
ReferenceCopyLocalPaths = referenceAssemblyPaths
};
weavingTask.Execute();
moduleDefinition.Write(newAssembly);
Assembly = Assembly.LoadFrom(newAssembly);
}
开发者ID:GavinOsborn,项目名称:MethodTimer,代码行数:35,代码来源:AssemblyWeaver.cs
示例12: FieldToPropertyForwarder
public FieldToPropertyForwarder(ModuleWeaver moduleWeaver, FieldToPropertyConverter fieldToPropertyConverter, MsCoreReferenceFinder msCoreReferenceFinder, MethodFinder methodFinder)
{
this.moduleWeaver = moduleWeaver;
this.msCoreReferenceFinder = msCoreReferenceFinder;
this.methodFinder = methodFinder;
forwardedFields = fieldToPropertyConverter.ForwardedFields;
}
开发者ID:Fody,项目名称:Fielder,代码行数:7,代码来源:FieldToPropertyForwarder.cs
示例13: WeaverHelper
public WeaverHelper(string assemblyToProcess)
{
var assemblyFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
BeforeAssemblyPath = Path.Combine(assemblyFolder, assemblyToProcess);
AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, new ReaderParameters());
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
LogDebug = s => System.Diagnostics.Debug.WriteLine(s, "Debug"),
LogInfo = s => System.Diagnostics.Debug.WriteLine(s, "Info"),
LogWarning = s => System.Diagnostics.Debug.WriteLine(s, "Warning"),
LogError = s => System.Diagnostics.Debug.WriteLine(s, "Error"),
};
weavingTask.Execute();
moduleDefinition.Write(AfterAssemblyPath);
//ProvideIlStepThrough(AfterAssemblyPath);
Assembly = Assembly.LoadFile(AfterAssemblyPath);
}
开发者ID:adbancroft,项目名称:WeakEvents.Fody,代码行数:25,代码来源:WeaverHelper.cs
示例14: WithIncludesTests
public WithIncludesTests()
{
beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory,@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "3.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var assemblyResolver = new MockAssemblyResolver
{
Directory = Path.GetDirectoryName(beforeAssemblyPath)
};
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
{
AssemblyResolver = assemblyResolver
});
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
IncludeNamespaces = new List<string>{"MyNameSpace"},
LogWarning =s => warnings.Add(s)
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
assembly = Assembly.LoadFile(afterAssemblyPath);
}
开发者ID:Fody,项目名称:EmptyConstructor,代码行数:31,代码来源:WithIncludesTests.cs
示例15: Setup
public void Setup()
{
var projectPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\AssemblyToProcess\AssemblyToProcess.csproj"));
assemblyPath = Path.Combine(Path.GetDirectoryName(projectPath), @"bin\Debug\AssemblyToProcess.dll");
#if (!DEBUG)
assemblyPath = assemblyPath.Replace("Debug", "Release");
#endif
newAssemblyPath = assemblyPath.Replace(".dll", "2.dll");
shadowAssemblyPath = assemblyPath.Replace(".dll", "2shadow.dll");
File.Copy(assemblyPath, newAssemblyPath, true);
File.Copy(assemblyPath, shadowAssemblyPath, true);
var moduleDefinition = ModuleDefinition.ReadModule(newAssemblyPath);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition
};
weavingTask.Execute();
moduleDefinition.Write(newAssemblyPath);
assembly = Assembly.LoadFile(newAssemblyPath);
}
开发者ID:qkub,项目名称:ExpandoIntelligizer,代码行数:25,代码来源:WeaverTests.cs
示例16: CanParseStepType
public void CanParseStepType()
{
var xElement = XElement.Parse(@"<Obsolete StepType='Minor'/>");
var moduleWeaver = new ModuleWeaver {Config = xElement};
moduleWeaver.ReadConfig();
Assert.AreEqual(StepType.Minor, moduleWeaver.StepType);
}
开发者ID:Fody,项目名称:Obsolete,代码行数:7,代码来源:ConfigReaderTests.cs
示例17: VerifyAssembly
public void VerifyAssembly(string assemblyPath)
{
Debug.WriteLine("Verifying " + assemblyPath);
var cleanAssembly = assemblyPath.Replace(".dll", "2.dll");
var newAssembly = assemblyPath.Replace(".dll", "3.dll");
File.Copy(assemblyPath, cleanAssembly, true);
File.Copy(assemblyPath, newAssembly, true);
var assemblyResolver = new MockAssemblyResolver();
var moduleDefinition = ModuleDefinition.ReadModule(cleanAssembly);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
};
moduleDefinition.Write(cleanAssembly);
moduleDefinition = ModuleDefinition.ReadModule(newAssembly);
weavingTask.ModuleDefinition = moduleDefinition;
weavingTask.Execute();
moduleDefinition.Write(newAssembly);
Verifier.Verify(cleanAssembly, newAssembly);
}
开发者ID:dpisanu,项目名称:NullGuard,代码行数:25,代码来源:LargeAssemblyTest.cs
示例18: ThrowsNotImplementedText
public void ThrowsNotImplementedText()
{
var xElement = XElement.Parse(@"<Obsolete ThrowsNotImplementedText='Custom Text'/>");
var moduleWeaver = new ModuleWeaver {Config = xElement};
moduleWeaver.ReadConfig();
Assert.AreEqual("Custom Text", moduleWeaver.ThrowsNotImplementedText);
}
开发者ID:Fody,项目名称:Obsolete,代码行数:7,代码来源:ConfigReaderTests.cs
示例19: PropertyWeaver
public PropertyWeaver(ModuleWeaver moduleWeaver, PropertyData propertyData, TypeNode typeNode, TypeSystem typeSystem )
{
this.moduleWeaver = moduleWeaver;
this.propertyData = propertyData;
this.typeNode = typeNode;
this.typeSystem = typeSystem;
}
开发者ID:jbruening,项目名称:PropertyChanged,代码行数:7,代码来源:PropertyWeaver.cs
示例20: TrueHideObsoleteMembers
public void TrueHideObsoleteMembers()
{
var xElement = XElement.Parse(@"<Obsolete HideObsoleteMembers='true'/>");
var moduleWeaver = new ModuleWeaver {Config = xElement};
moduleWeaver.ReadConfig();
Assert.IsTrue(moduleWeaver.HideObsoleteMembers);
}
开发者ID:Fody,项目名称:Obsolete,代码行数:7,代码来源:ConfigReaderTests.cs
注:本文中的ModuleWeaver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论