public IllFormedSemanticModelException(string message, CSharpParameter badParameter) : base(message)
        {
            Contract.Requires(badParameter != null);

            BadParameter = badParameter;
            Kind         = CSharpKind.CSharpParameter;
        }
 public static bool ParametersAreEquivalent(CSharpParameter param1, CSharpParameter param2)
 {
     Contract.Requires(param1 != null);
     Contract.Requires(param2 != null);
     //return param1.Equals(param2); //Doesn't work for our purposes.
     if (param1.Type == null)
     {
         throw new IllFormedSemanticModelException("A CSharpParameter was found with a null 'Type' field.", param1);
     }
     if (param2.Type == null)
     {
         throw new IllFormedSemanticModelException("A CSharpParameter was found with a null 'Type' field.", param2);
     }
     if (!TypesAreEquivalent(param1.Type, param2.Type))
     {
         return(false);
     }
     if (param1.IsOut ^ param2.IsOut)
     {
         return(false);
     }
     if (param1.IsParams ^ param2.IsParams)
     {
         return(false);
     }
     if (param1.IsRef ^ param2.IsRef)
     {
         return(false);
     }
     if (param1.IsThis ^ param2.IsThis)
     {
         return(false);
     }
     return(true);
 }
        private IEnumerable <CSharpParameter> GetMethodParameters(OperationDefinition operation)
        {
            foreach (ParameterDefinition parameter in operation.Parameters)
            {
                CSharpParameter result = new CSharpParameter(
                    parameter.Name,
                    parameter.Type.GetCSharpName());

                yield return(result);
            }
        }
示例#4
0
        public bool TryGetParameterReference(CSharpParameter semanticParameter, ushort index, out IParameterTypeInformation cciParameter)
        {
            cciParameter = null;

            #region Check input
            if (semanticParameter == null)
            {
                return(false);
            }
            #endregion
            #region Set up our working cci parameter
            Microsoft.Cci.MutableCodeModel.ParameterTypeInformation workingParameter = null;
            cciParameter = workingParameter = new Microsoft.Cci.MutableCodeModel.ParameterTypeInformation();
            #endregion
            #region Get our parameter type
            ITypeReference paramType;
            if (!TryGetTypeReference(semanticParameter.Type, out paramType))
            {
                goto ReturnFalse;
            }
            workingParameter.Type = paramType;
            #endregion
            #region Get our index
            workingParameter.Index = index;
            #endregion
            #region Get our reference status
            workingParameter.IsByReference = semanticParameter.IsOut || semanticParameter.IsRef;
            #endregion
            #region ReturnTrue:
            //ReturnTrue:
            return(cciParameter != Dummy.ParameterTypeInformation);

            #endregion
            #region ReturnFalse:
ReturnFalse:
            if (semanticParameter.Name != null)
            {
                ContractsPackageAccessor.Current.Logger.WriteToLog("Failed to build parameter reference for: " + semanticParameter.Name.Text);
            }
            return(false);

            #endregion
        }
示例#5
0
        private IEnumerable <CSharpMethod> GetMethods(ContractDefinition contract)
        {
            IEnumerable <CSharpParameter> methodParameters = new CSharpParameter[]
            {
                new CSharpParameter(ImplementationParameterName, contract.FullName),
                new CSharpParameter(OperationInvocationParameterName, typeof(OperationInvocation).GetCSharpName()),
            };

            foreach (OperationDefinition operation in contract.Operations)
            {
                CSharpMethod result = new CSharpMethod(
                    name: operation.Name,
                    returnType: typeof(Task <object>).GetCSharpName(),
                    body: this.GetMethodBody(operation),
                    accessModifier: CSharpAccessModifier.Private,
                    parameters: methodParameters,
                    isStatic: true,
                    isAsync: true);

                yield return(result);
            }
        }
示例#6
0
 internal RuntimeParameterInfo(CSharpParameter parameter)
 {
     this.parameter = parameter;
 }
示例#7
0
    public bool TryGetParameterReference(CSharpParameter semanticParameter, ushort index, out IParameterTypeInformation cciParameter) {

      cciParameter = null;

      #region Check input
      if (semanticParameter == null) {
        return false;
      }
      #endregion
      #region Set up our working cci parameter
      Microsoft.Cci.MutableCodeModel.ParameterTypeInformation workingParameter = null;
      cciParameter = workingParameter = new Microsoft.Cci.MutableCodeModel.ParameterTypeInformation();
      #endregion
      #region Get our parameter type
      ITypeReference paramType;
      if (!TryGetTypeReference(semanticParameter.Type, out paramType))
        goto ReturnFalse;
      workingParameter.Type = paramType;
      #endregion
      #region Get our index
      workingParameter.Index = index;
      #endregion
      #region Get our reference status
      workingParameter.IsByReference = semanticParameter.IsOut || semanticParameter.IsRef;
      #endregion
      #region ReturnTrue:
    //ReturnTrue:
      return cciParameter != Dummy.ParameterTypeInformation;
      #endregion
      #region ReturnFalse:
    ReturnFalse:
      if (semanticParameter.Name != null)
      {
        VSServiceProvider.Current.Logger.WriteToLog("Failed to build parameter reference for: " + semanticParameter.Name.Text);
      }
      return false;
      #endregion
    }