Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Metadata generation failed' when updating Microsoft.NET.Sdk.Functions to 4.1.3 #592

Open
JasonAndersen7 opened this issue Oct 18, 2022 · 7 comments

Comments

@JasonAndersen7
Copy link

I am trying to update an Azure Function project from .NET Core 3.1 to .NET 6. When updating the Microsoft.NET.Sdk.Functions from 3.0.11 to 4.1.3 or later, I can no longer build the project. Instead, I get the following errors in the Error List:

  • System.ArgumentException: Object of type 'Mono.Cecil.TypeReference' cannot be converted to type 'System.Type''.
  • Metadata generation failed.

Similar to #585
This problem seems to be introduced by #547.

Error System.ArgumentException: Object of type 'Mono.Cecil.TypeReference' cannot be converted to type 'System.Type'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& stackArgs, ReadOnlySpan1 parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at MakeFunctionJson.TypeUtility.ToReflection(CustomAttribute customAttribute) in /_/src/Microsoft.NET.Sdk.Functions.Generator/TypeUtility.cs:line 106 at MakeFunctionJson.TypeUtility.GetResolvedAttribute(ParameterDefinition parameter, CustomAttribute customAttribute) in /_/src/Microsoft.NET.Sdk.Functions.Generator/TypeUtility.cs:line 67 at MakeFunctionJson.ParameterInfoExtensions.<>c__DisplayClass1_0.<ToFunctionJsonBindings>b__1(CustomAttribute a) in /_/src/Microsoft.NET.Sdk.Functions.Generator/ParameterInfoExtensions.cs:line 32 at System.Linq.Utilities.<>c__DisplayClass2_03.b__0(TSource x)
at System.Linq.Utilities.<>c__DisplayClass2_03.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at MakeFunctionJson.ParameterInfoExtensions.ToFunctionJsonBindings(ParameterDefinition parameterInfo) in /_/src/Microsoft.NET.Sdk.Functions.Generator/ParameterInfoExtensions.cs:line 29 at MakeFunctionJson.MethodInfoExtensions.<>c.<ToFunctionJson>b__6_0(ParameterDefinition p) in /_/src/Microsoft.NET.Sdk.Functions.Generator/MethodInfoExtensions.cs:line 66 at System.Linq.Enumerable.SelectIListIterator2.MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items) at System.Collections.Generic.SparseArrayBuilder1.ReserveOrAdd(IEnumerable1 items) at System.Linq.Enumerable.Concat2Iterator1.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at MakeFunctionJson.MethodInfoExtensions.ToFunctionJson(MethodDefinition method, String assemblyPath) in /_/src/Microsoft.NET.Sdk.Functions.Generator/MethodInfoExtensions.cs:line 65 at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable1 types)+MoveNext() in //src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs:line 140
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons() in /
/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs:line 194
at MakeFunctionJson.FunctionJsonConverter.TryRun() in /_/src/Microsoft.NET.Sdk.Functions.Generator/FunctionJsonConverter.cs:line 87

File : Microsoft.NET.Sdk.Functions.Build.targets

@kshyju
Copy link
Member

kshyju commented Oct 18, 2022

4.1.3 or later, I can no longer build the project.

Just to confirm, If you downgrade to 4.1.2 version of Microsoft.NET.Sdk.Functions, build works?

@JasonAndersen7
Copy link
Author

Hello kshyju,
Thank you for responding, we were able to use version 4.0.0 and version 4.0.1 but for all other versions later than 4.0.1 the build does not work

@kshyju
Copy link
Member

kshyju commented Oct 19, 2022

@JasonAndersen7 I could not repro this issue. Would you be able to share a minimal repro? A GitHub repo will be great.

@ghost
Copy link

ghost commented Oct 23, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@JasonAndersen7
Copy link
Author

HI Kshyju,
I was mainly curious to see if this is a known issue or not.
Unfortunately our code is proprietary and cannot be shared
Thank you for your assistance

@ramya894
Copy link

ramya894 commented Nov 2, 2022

@kshyju Can you check the above comments.

@tbetts42
Copy link

tbetts42 commented Feb 1, 2023

I encountered a similar issue that brought me here.
I've created a small GitHub repo to reproduce the error:
https://github.com/tbetts42/AzureFunctionsBuildTest
More details are in the Readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants