本文整理汇总了C#中IMethodSignature类的典型用法代码示例。如果您正苦于以下问题:C# IMethodSignature类的具体用法?C# IMethodSignature怎么用?C# IMethodSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMethodSignature类属于命名空间,在下文中一共展示了IMethodSignature类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CheckParametersAndValues
void CheckParametersAndValues (IMetadataTokenProvider provider, IMethodSignature constructor, IList<CustomAttributeArgument> arguments)
{
for (int index = 0; index < arguments.Count; index++) {
ParameterDefinition parameter = constructor.Parameters[index];
if (parameter.ParameterType.IsNamed ("System", "String")) {
string value = (string) arguments [index].Value;
if (Contains (parameter.Name, "version")) {
Version v = null;
if (!Version.TryParse (value, out v)) {
string msg = String.Format (CultureInfo.InvariantCulture, "The value passed: {0} can't be parsed to a valid Version.", value);
Runner.Report (provider, Severity.High, Confidence.High, msg);
}
continue;
}
if (Contains (parameter.Name, "url") ||
Contains (parameter.Name, "uri") ||
Contains (parameter.Name, "urn")) {
Uri parsed = null;
if (!Uri.TryCreate (value, UriKind.Absolute, out parsed)) {
string msg = String.Format (CultureInfo.InvariantCulture, "The valued passed {0} can't be parsed to a valid Uri.", value);
Runner.Report (provider, Severity.High, Confidence.High, msg);
}
continue;
}
if (Contains (parameter.Name, "guid")) {
Guid g;
if (!Guid.TryParse (value, out g)) {
string msg = String.Format (CultureInfo.InvariantCulture, "The valued passed {0} can't be parsed to a valid Guid.", value);
Runner.Report (provider, Severity.High, Confidence.High, msg);
}
continue;
}
}
}
}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:35,代码来源:AttributeStringLiteralsShouldParseCorrectlyRule.cs
示例2: CompareSignature
/// <summary>
/// Compare the IMethodSignature members with the one being specified.
/// </summary>
/// <param name="self">>The IMethodSignature on which the extension method can be called.</param>
/// <param name="signature">The IMethodSignature which is being compared.</param>
/// <returns>True if the IMethodSignature members are identical, false otherwise</returns>
public static bool CompareSignature(this IMethodSignature self, IMethodSignature signature)
{
if (self == null)
return (signature == null);
if (self.HasThis != signature.HasThis)
return false;
if (self.ExplicitThis != signature.ExplicitThis)
return false;
if (self.CallingConvention != signature.CallingConvention)
return false;
if (!AreSameElementTypes(self.ReturnType, signature.ReturnType))
return false;
bool h1 = self.HasParameters;
bool h2 = signature.HasParameters;
if (h1 != h2)
return false;
if (!h1 && !h2)
return true;
IList<ParameterDefinition> pdc1 = self.Parameters;
IList<ParameterDefinition> pdc2 = signature.Parameters;
int count = pdc1.Count;
if (count != pdc2.Count)
return false;
for (int i = 0; i < count; ++i)
{
if (!AreSameElementTypes(pdc1[i].ParameterType, pdc2[i].ParameterType))
return false;
}
return true;
}
开发者ID:mdabbagh88,项目名称:arrayslice,代码行数:41,代码来源:MethodRocks.cs
示例3: CheckReturnVoid
private bool CheckReturnVoid (IMetadataTokenProvider eventType, IMethodSignature invoke)
{
string full_name = invoke.ReturnType.FullName;
if (String.Compare (full_name, "System.Void") == 0)
return true;
string msg = String.Format ("The delegate should return void, not {0}", full_name);
Runner.Report (eventType, Severity.Medium, Confidence.High, msg);
return false;
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:10,代码来源:DeclareEventHandlersCorrectlyRule.cs
示例4: AppendMethodSignature
//TODO: Consider creating a class that will represent member signature
private static void AppendMethodSignature(StringBuilder scope, IMethodSignature method)
{
scope.Append(method.HasThis ? 's' : 'i');
scope.Append(' ');
scope.Append(method.CallingConvention.ToString());
scope.Append(' ');
AppendTypeSignature(scope, method.ReturnType);
scope.Append(' ');
AppendParametersString(scope, method.Parameters);
}
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:12,代码来源:CTSNameGenerator.cs
示例5: MethodSignatureFullName
public static void MethodSignatureFullName (IMethodSignature self, StringBuilder builder)
{
builder.Append ("(");
if (self.HasParameters) {
var parameters = self.Parameters;
for (int i = 0; i < parameters.Count; i++) {
var parameter = parameters [i];
if (i > 0)
builder.Append (",");
if (parameter.ParameterType.IsSentinel)
builder.Append ("...,");
builder.Append (parameter.ParameterType.FullName);
}
}
builder.Append (")");
}
开发者ID:FreshBirdZhe,项目名称:LSharp,代码行数:20,代码来源:IMethodSignature.cs
示例6: MakeByRefCallSimple
void MakeByRefCallSimple(SsaBlock block, ref int instructionIndexInBlock, IMethodSignature targetMethod)
{
SsaInstruction inst = block.Instructions[instructionIndexInBlock];
for (int i = 0; i < inst.Operands.Length; i++) {
SsaVariable operand = inst.Operands[i];
if (operand.IsSingleAssignment && operand.Usage.Count == 1 && IsLoadAddress(operand.Definition)) {
// address is used for this method call only
Instruction loadAddressInstruction = operand.Definition.Instruction;
// find target parameter type:
bool isOut;
if (i == 0 && targetMethod.HasThis) {
isOut = false;
} else {
ParameterDefinition parameter = targetMethod.Parameters[i - (targetMethod.HasThis ? 1 : 0)];
isOut = parameter.IsOut;
}
SsaVariable addressTakenOf = GetVariableFromLoadAddressInstruction(loadAddressInstruction);
// insert "Prepare" instruction on front
SpecialOpCode loadOpCode = isOut ? SpecialOpCode.PrepareByOutCall : SpecialOpCode.PrepareByRefCall;
block.Instructions.Insert(instructionIndexInBlock++, new SsaInstruction(
block, null, operand, new SsaVariable[] { addressTakenOf }, specialOpCode: loadOpCode));
// insert "WriteAfterByRefOrOutCall" instruction after call
block.Instructions.Insert(instructionIndexInBlock + 1, new SsaInstruction(
block, null, addressTakenOf, new SsaVariable[] { operand }, specialOpCode: SpecialOpCode.WriteAfterByRefOrOutCall));
couldSimplifySomething = true;
// remove the loadAddressInstruction later
// (later because it might be defined in the current block and we don't want instructionIndex to become invalid)
redundantLoadAddressInstructions.Add(operand.Definition);
}
}
}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:38,代码来源:SimplifyByRefCalls.cs
示例7: EmitCanReplace
private void EmitCanReplace(CilWorker IL, IMethodSignature hostMethod, VariableDefinition provider)
{
var skipGetProvider = IL.Create(OpCodes.Nop);
IL.Emit(OpCodes.Ldloc, provider);
IL.Emit(OpCodes.Brfalse, skipGetProvider);
IL.Emit(OpCodes.Ldloc, provider);
// Push the host instance
var pushInstance = hostMethod.HasThis ? IL.Create(OpCodes.Ldarg_0) : IL.Create(OpCodes.Ldnull);
IL.Append(pushInstance);
IL.Emit(OpCodes.Ldloc, _invocationInfo);
IL.Emit(OpCodes.Callvirt, _canReplace);
IL.Emit(OpCodes.Stloc, _canReplaceFlag);
IL.Append(skipGetProvider);
}
开发者ID:zxl359592450,项目名称:linfu,代码行数:18,代码来源:InterceptMethodCalls.cs
示例8: GetResultTreatment
public override PexResultTracking GetResultTreatment(PexTrackingThread thread, int callId,
IMethodSignature methodSignature, TypeEx[] varArgTypes,
bool hasDerivedResult)
{
// track uninstrumented method calls
if (!hasDerivedResult)
{
var method = methodSignature as Method;
if (method.FullName.Equals(_trackMethod.FullName))
{
if (track)
{
Dump("start to track " + method.FullName);
TrackingMethods.Add(method);
return PexResultTracking.Track;
}
Dump("method " + method.FullName + " is not tracked!");
}
// IssueTrackDatabase db;
// if (host.TryGetService<IssueTrackDatabase>(out db))
// {
//// host.Log.Dump("size", "size", "uninstrumented methods: " + db.UnInstrumentedMethods.Count);
// foreach (var uninstrumentedMethod in db.UnInstrumentedMethods)
// {
//// host.Log.Dump("Method", "Method", "uninstrumented methods: " + uninstrumentedMethod.Method.FullName);
//// host.Log.Dump("Method", "Method2", "methods: " + method.Definition.FullName);
// if (uninstrumentedMethod.Method.FullName.Equals(method.FullName))
// {
//// host.Log.Dump("Method", "track", "track: " + method.Definition.FullName);
// if (TrackingMethods.Add(method))
// {
// return PexResultTracking.Track;
// }
// }
// }
// }
}
return PexResultTracking.ConcreteOrDerived;
}
开发者ID:spati2,项目名称:ICSE-2011-Covana,代码行数:41,代码来源:ResultTracingObserver.cs
示例9: MethodReturnType
public MethodReturnType(IMethodSignature method)
{
this.method = method;
}
开发者ID:hjlfmy,项目名称:cecil,代码行数:4,代码来源:MethodReturnType.cs
示例10: GetSentinelPosition
public static int GetSentinelPosition(IMethodSignature ms)
{
if (!ms.HasParameters)
return -1;
var parameters = ms.Parameters;
for (int i = 0; i < parameters.Count; i++)
if (parameters[i].ParameterType.IsSentinel)
return i;
return -1;
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:12,代码来源:InsUtils.cs
示例11: ParameterDefinition
internal ParameterDefinition (TypeReference parameterType, IMethodSignature method)
: this (string.Empty, ParameterAttributes.None, parameterType)
{
this.method = method;
}
开发者ID:mayuki,项目名称:Inazuma,代码行数:5,代码来源:ParameterDefinition.cs
示例12: FindImpurity
private MethodReference FindImpurity (IMethodSignature method, Instruction end)
{
MethodReference impure = null;
Instruction ins = FullTraceBack (method, end);
if (ins != null) {
Log.WriteLine (this, "checking args for call at {0:X4} starting at {1:X4}", end.Offset, ins.Offset);
while (ins.Offset < end.Offset && impure == null) {
if (ins.OpCode.Code == Code.Call || ins.OpCode.Code == Code.Callvirt) {
MethodReference candidate = ins.Operand as MethodReference;
if (!IsPure (candidate))
return candidate;
}
ins = ins.Next;
}
}
return impure;
}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:19,代码来源:AvoidMethodsWithSideEffectsInConditionalCodeRule.cs
示例13: FullTraceBack
// This is like the TraceBack rock except that it continues traversing backwards
// until it finds an instruction which does not pop any values off the stack. This
// allows us to check all of the instructions used to compute the method's
// arguments.
internal static Instruction FullTraceBack (IMethodSignature method, Instruction end)
{
Instruction first = end.TraceBack (method);
while (first != null && first.GetPopCount (method) > 0) {
first = first.TraceBack (method);
}
return first;
}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:14,代码来源:AvoidMethodsWithSideEffectsInConditionalCodeRule.cs
示例14: CheckParameters
private void CheckParameters (IMethodSignature concat, MethodDefinition caller, Instruction ins)
{
// check for boxed (likely char, but could be other types too) on any parameter
for (int i = 0; i < concat.Parameters.Count; i++) {
Instruction source = ins.TraceBack (caller, -i);
if ((source == null) || (source.OpCode.Code != Code.Box))
continue;
ReportBoxing (caller, source, Confidence.High);
}
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:10,代码来源:AvoidConcatenatingCharsRule.cs
示例15: PopulateMethodParameters
private static void PopulateMethodParameters(IMethodSignature member,
CodeParameterDeclarationExpressionCollection parameters, bool isExtension = false)
{
foreach (var parameter in member.Parameters)
{
FieldDirection direction = 0;
if (parameter.IsOut)
direction |= FieldDirection.Out;
else if (parameter.ParameterType.IsByReference)
direction |= FieldDirection.Ref;
var parameterType = parameter.ParameterType.IsByReference
? parameter.ParameterType.GetElementType()
: parameter.ParameterType;
var type = CreateCodeTypeReference(parameterType);
if (isExtension)
{
type = ModifyCodeTypeReference(type, "this");
isExtension = false;
}
var name = parameter.HasConstant
? string.Format("{0} = {1}", parameter.Name, FormatParameterConstant(parameter))
: parameter.Name;
var expression = new CodeParameterDeclarationExpression(type, name)
{
Direction = direction,
CustomAttributes = CreateCustomAttributes(parameter)
};
parameters.Add(expression);
}
}
开发者ID:Particular,项目名称:ServiceControl.Plugin.Nsb6.CustomChecks,代码行数:34,代码来源:PublicApiGenerator.cs
示例16: TraceBack
/// <summary>
/// Return the instruction that match the current instruction. This is computed by
/// substracting push and adding pop counts until the total becomes zero.
/// </summary>
/// <param name="self">The Instruction on which the extension method can be called.</param>
/// <param name="method">The method from which the instruction was extracted.</param>
/// <returns>The instruction that match the current instruction.</returns>
public static Instruction TraceBack (this Instruction self, IMethodSignature method)
{
return TraceBack (self, method, 0);
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:11,代码来源:InstructionRocks.cs
示例17: GetParameters
public static List<CompParameter> GetParameters(IMethodSignature provider)
{
var l = new List<CompParameter> ();
foreach (ParameterDefinition pd in provider.Parameters)
{
l.Add (new CecilParameter (pd));
}
return l;
}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:10,代码来源:CecilMetadata.cs
示例18: CheckParameterTypes
private bool CheckParameterTypes (IMetadataTokenProvider eventType, IMethodSignature invoke)
{
bool ok = true;
if (!invoke.HasParameters)
return ok;
IList<ParameterDefinition> pdc = invoke.Parameters;
if (pdc.Count >= 1) {
string type_name = pdc [0].ParameterType.FullName;
if (String.Compare (type_name, "System.Object") != 0) {
Runner.Report (eventType, Severity.Medium, Confidence.High, String.Format ("The first parameter should have an object, not {0}", type_name));
ok = false;
}
}
if (pdc.Count >= 2) {
if (!pdc [1].ParameterType.Inherits ("System.EventArgs")) {
Runner.Report (eventType, Severity.Medium, Confidence.High, "The second parameter should be a subclass of System.EventArgs");
ok = false;
}
}
return ok;
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:22,代码来源:DeclareEventHandlersCorrectlyRule.cs
示例19: CompareParameters
private static bool CompareParameters (IMethodSignature m1, IMethodSignature m2)
{
bool h1 = m1.HasParameters;
bool h2 = m2.HasParameters;
if (h1 != h2)
return false;
if (!h1 && !h2)
return true;
IList<ParameterDefinition> pdc1 = m1.Parameters;
IList<ParameterDefinition> pdc2 = m2.Parameters;
if (pdc1.Count != pdc2.Count)
return false;
for (int i = 0; i < pdc1.Count; ++i) {
if (!AreSameElementTypes (pdc1 [i].ParameterType, pdc2 [i].ParameterType))
return false;
}
return true;
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:20,代码来源:ConsiderAddingInterfaceRule.cs
示例20: CheckAmountOfParameters
private bool CheckAmountOfParameters (IMetadataTokenProvider eventType, IMethodSignature invoke)
{
if (invoke.HasParameters && (invoke.Parameters.Count == 2))
return true;
Runner.Report (eventType, Severity.Medium, Confidence.High, "The delegate should have 2 parameters");
return false;
}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:8,代码来源:DeclareEventHandlersCorrectlyRule.cs
注:本文中的IMethodSignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论