Beispiel #1
0
        private IMethodReference GetCorrespondingThreeArgContractMethod(IMethodReference originalMethod)
        {
            ushort genericParameters  = 0;
            string contractMethodName = originalMethod.Name.Value;
            string keyName            = contractMethodName;
            IGenericMethodInstanceReference methodInstance = originalMethod as IGenericMethodInstanceReference;

            if (methodInstance != null)
            {
                originalMethod    = methodInstance.GenericMethod;
                genericParameters = originalMethod.GenericParameterCount;
                keyName           = originalMethod.Name.Value + genericParameters;
            }

            #region Backward compatibility with v4 Beta 1 which went out with RequiresAlways in it (REMOVE WHEN THAT IS DELETED)
            bool backwardCompat = false;
            if (contractMethodName.Equals("RequiresAlways"))
            {
                contractMethodName = "Requires1"; // The one is for the generic parameter
                genericParameters  = 1;
                backwardCompat     = true;
            }
            #endregion Backward compatibility with v4 Beta 1 which went out with RequiresAlways in it (REMOVE WHEN THAT IS DELETED)

            IMethodReference methodToUse;
            this.threeArgumentVersionofContractMethod.TryGetValue(keyName, out methodToUse);
            if (methodToUse == null)
            {
                #region Create a method
                methodToUse = CreateThreeArgVersionOfMethod(contractMethodName, keyName, genericParameters, backwardCompat);
                #endregion Create a method
            }
            if (genericParameters != 0)
            {
                // instantiate method to use
                methodToUse = new Microsoft.Cci.Immutable.GenericMethodInstanceReference(methodToUse,
                                                                                         backwardCompat ? IteratorHelper.GetSingletonEnumerable <ITypeReference>(this.systemArgumentExceptionType) : methodInstance.GenericArguments,
                                                                                         this.host.InternFactory);
                var key = methodToUse.InternedKey;
            }
            return(methodToUse);
        }
Beispiel #2
0
    private IMethodReference GetCorrespondingThreeArgContractMethod(IMethodReference originalMethod) {
      ushort genericParameters = 0;
      string contractMethodName = originalMethod.Name.Value;
      string keyName = contractMethodName;
      IGenericMethodInstanceReference methodInstance = originalMethod as IGenericMethodInstanceReference;
      if (methodInstance != null) {
        originalMethod = methodInstance.GenericMethod;
        genericParameters = originalMethod.GenericParameterCount;
        keyName = originalMethod.Name.Value + genericParameters;
      }

      #region Backward compatibility with v4 Beta 1 which went out with RequiresAlways in it (REMOVE WHEN THAT IS DELETED)
      bool backwardCompat = false;
      if (contractMethodName.Equals("RequiresAlways")) {
        contractMethodName = "Requires1"; // The one is for the generic parameter
        genericParameters = 1;
        backwardCompat = true;
      }
      #endregion Backward compatibility with v4 Beta 1 which went out with RequiresAlways in it (REMOVE WHEN THAT IS DELETED)

      IMethodReference methodToUse;
      this.threeArgumentVersionofContractMethod.TryGetValue(keyName, out methodToUse);
      if (methodToUse == null) {
        #region Create a method
        methodToUse = CreateThreeArgVersionOfMethod(contractMethodName, keyName, genericParameters, backwardCompat);
        #endregion Create a method
      }
      if (genericParameters != 0) {
        // instantiate method to use
        methodToUse = new Microsoft.Cci.Immutable.GenericMethodInstanceReference(methodToUse,
          backwardCompat ? IteratorHelper.GetSingletonEnumerable<ITypeReference>(this.systemArgumentExceptionType) : methodInstance.GenericArguments,
          this.host.InternFactory);
        var key = methodToUse.InternedKey;
      }
      return methodToUse;
    }