Esempio n. 1
0
        public void Test_GetActionName_ReturnsName(MethodStyle style, string expected)
        {
            var matcher  = testEnvironment.ServiceProvider.GetRequiredService <MethodMatcher>();
            var metadata = new MethodMetadata(new JsonRpcMethodOptions()
            {
                MethodStyle = style
            }, new JsonName("", "controller"), new JsonName("", "action"));
            var result = matcher.GetActionName(metadata);

            result.Should().Be(expected);
        }
Esempio n. 2
0
        public MethodDef
            (IImSeq <Annotation> annotations,
            ISeq <CustomAttribute> customAttributes,
            string name,
            bool isStatic,
            IImSeq <ParameterTypeDef> typeParameters,
            IImSeq <ParameterOrLocalOrResult> valueParameters,
            ParameterOrLocalOrResult result,
            MethodStyle methodStyle,
            bool hasNewSlot,
            MethodCodeFlavor codeFlavor,
            bool isSyncronized,
            bool noInlining,
            bool isInitLocals,
            IImSeq <ParameterOrLocalOrResult> locals,
            PE.MethodBody methodBody)
            : base(annotations, customAttributes, name, isStatic)
        {
            TypeParameters   = typeParameters ?? Constants.EmptyParameterTypeDefs;
            ValueParameters  = valueParameters ?? Constants.EmptyParameterOrLocals;
            Result           = result;
            this.methodStyle = methodStyle;
            HasNewSlot       = hasNewSlot;
            CodeFlavor       = codeFlavor;
            var noBody = methodStyle == MethodStyle.Abstract || CodeFlavor != MethodCodeFlavor.Managed;

            IsSyncronized = isSyncronized;
            NoInlining    = noInlining;
            IsInitLocals  = isInitLocals;
            if (noBody && locals != null && locals.Count > 0)
            {
                throw new InvalidOperationException("unexpected locals in method");
            }
            Locals = locals ?? Constants.EmptyParameterOrLocals;
            if (noBody && methodBody != null)
            {
                throw new InvalidOperationException("unexpected instructions in extern method definition");
            }
            if (!noBody && methodBody == null)
            {
                throw new InvalidOperationException("missing instructions in method definition");
            }
            MethodBody = methodBody;
        }
 public JsonRpcMethodStyleAttribute(MethodStyle methodStyle)
 {
     MethodStyle = methodStyle;
 }
Esempio n. 4
0
 public MethodDef
     (IImSeq<Annotation> annotations,
      ISeq<CustomAttribute> customAttributes,
      string name,
      bool isStatic,
      IImSeq<ParameterTypeDef> typeParameters,
      IImSeq<ParameterOrLocalOrResult> valueParameters,
      ParameterOrLocalOrResult result,
      MethodStyle methodStyle,
      bool hasNewSlot,
      MethodCodeFlavor codeFlavor,
      bool isSyncronized,
      bool noInlining,
      bool isInitLocals,
      IImSeq<ParameterOrLocalOrResult> locals,
      PE.MethodBody methodBody)
     : base(annotations, customAttributes, name, isStatic)
 {
     TypeParameters = typeParameters ?? Constants.EmptyParameterTypeDefs;
     ValueParameters = valueParameters ?? Constants.EmptyParameterOrLocals;
     Result = result;
     this.methodStyle = methodStyle;
     HasNewSlot = hasNewSlot;
     CodeFlavor = codeFlavor;
     var noBody = methodStyle == MethodStyle.Abstract || CodeFlavor != MethodCodeFlavor.Managed;
     IsSyncronized = isSyncronized;
     NoInlining = noInlining;
     IsInitLocals = isInitLocals;
     if (noBody && locals != null && locals.Count > 0)
         throw new InvalidOperationException("unexpected locals in method");
     Locals = locals ?? Constants.EmptyParameterOrLocals;
     if (noBody && methodBody != null)
         throw new InvalidOperationException("unexpected instructions in extern method definition");
     if (!noBody && methodBody == null)
         throw new InvalidOperationException("missing instructions in method definition");
     MethodBody = methodBody;
 }