Błąd zaraz po instalacji T4MVC

0

Otrzymuje taki błąd zaraz po zainstalowaniu z negut T4MVC:

Error	2	Running transformation: System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Microsoft.CodeAnalysis.CSharp.Symbols.ParameterSymbol.get_ExplicitDefaultValue()
   at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.ExternalElements.ExternalCodeParameter.get_DefaultValue()
   at EnvDTE80.CodeParameter2.get_DefaultValue()
   at Microsoft.VisualStudio.TextTemplating3DA3A5F10F01CBDA3C5C5AB50C7605308F57F7E53B727BF27A3F1EB3977B3E0E0352080FCF847610DD785A939638DA82C05F8EDCFBEF293FE35EA137024558CF.GeneratedTextTransformation.FunctionInfo..ctor(CodeFunction2 method) in (...)\T4MVC.tt:line 1985
   at Microsoft.VisualStudio.TextTemplating3DA3A5F10F01CBDA3C5C5AB50C7605308F57F7E53B727BF27A3F1EB3977B3E0E0352080FCF847610DD785A939638DA82C05F8EDCFBEF293FE35EA137024558CF.GeneratedTextTransformation.ResultTypeInfo.<get_AbstractMethods>b__6e(CodeFunction2 f) in (...)\T4MVC.tt:line 2133
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Microsoft.VisualStudio.TextTemplating3DA3A5F10F01CBDA3C5C5AB50C7605308F57F7E53B727BF27A3F1EB3977B3E0E0352080FCF847610DD785A939638DA82C05F8EDCFBEF293FE35EA137024558CF.GeneratedTextTransformation.TransformText() in (...)\T4MVC.tt:line 122	(...)\T4MVC.tt	1985	1	NetBlog
 

Co może być nie tak?

0

Musisz edytować T4MVC.tt, właściwie jedynie jeden konstruktor:

public FunctionInfo(CodeFunction2 method)
    {
        Parameters = new List<MethodParamInfo>();

        // Can be null when an custom ActionResult has no ctor
        if (method == null)
            return;

        _method = method;

        // Build a unique signature for the method, used to avoid duplication
        _signature = method.Name;

        CanBeCalledWithoutParameters = true;

        // Process all the parameters
        foreach (var p in method.Parameters.OfType<CodeParameter2>())
        {
            // If any param is not optional, then the method can't be called without parameters
            if (p.ParameterKind != vsCMParameterKind.vsCMParameterKindOptional)
            {
                CanBeCalledWithoutParameters = false;
            }

            // Note: if the param name starts with @ (e.g. to escape a keyword), we need to trim that
            string routeNameExpression = "\"" + p.Name.TrimStart('@') + "\"";

            // If there is a [Bind(Prefix = "someName")] attribute, use it
            if (p.InfoLocation != vsCMInfoLocation.vsCMInfoLocationExternal)
            {
                var attrib = GetAttribute(p.Attributes, "System.Web.Mvc.BindAttribute");
                if (attrib != null)
                {
                    var arg = attrib.Arguments.OfType<CodeAttributeArgument>().FirstOrDefault(a => a.Name == "Prefix");
                    if (arg != null)
                        routeNameExpression = arg.Value;
                }
            }
            
			try
			{
				Parameters.Add(
					new MethodParamInfo()
					{
						Name = p.Name,
						RouteNameExpression = routeNameExpression,
						Type = p.Type.AsString,
						DefaultValue = p.DefaultValue
					});
			}
			catch (System.InvalidOperationException)
			{
				Parameters.Add(
					new MethodParamInfo()
					{
						Name = p.Name,
						RouteNameExpression = routeNameExpression,
						Type = p.Type.AsString,
						DefaultValue = string.Empty
					});
			}
            _signature += "," + p.Type.AsString;
        }
    } 

1 użytkowników online, w tym zalogowanych: 0, gości: 1