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

GitReleaseManager doesn't run under .NET 7.0 - need to remove support for .NET 4.8 #530

Closed
SimonCropp opened this issue Sep 21, 2023 · 10 comments · Fixed by #545
Closed
Assignees
Milestone

Comments

@SimonCropp
Copy link
Contributor

https://github.com/VerifyTests/Verify/actions/runs/6254973775/job/16983521929

will look into is more and add details as i find them.

[FTL] GenericArguments[0], 'System.DateTimeOffset', on 'T MaxInteger[T](System.Collections.Generic.IEnumerable`1[T])' violates the constraint of type 'T'.
System.ArgumentException: GenericArguments[0], 'System.DateTimeOffset', on 'T MaxInteger[T](System.Collections.Generic.IEnumerable`1[T])' violates the constraint of type 'T'.
 ---> System.Security.VerificationException: Method System.Linq.Enumerable.MaxInteger: type argument 'System.DateTimeOffset' violates the constraint of type parameter 'T'.
   at System.RuntimeMethodHandle.GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[] methodInstantiation)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   --- End of inner exception stack trace ---
   at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at AutoMapper.TypeDetails.<>c__DisplayClass28_1.<BuildPublicNoArgExtensionMethods>b__10(MethodInfo extensionMethod)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.SelectManyIterator[TSource,TCollection,TResult](IEnumerable`1 source, Func`2 collectionSelector, Func`3 resultSelector)+MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
   at System.Linq.Enumerable.UnionIterator`1.FillSet()
   at System.Linq.Enumerable.UnionIterator`1.ToArray()
   at AutoMapper.TypeDetails.BuildPublicNoArgExtensionMethods(IEnumerable`1 sourceExtensionMethodSearch)
   at AutoMapper.TypeDetails..ctor(Type type, ProfileMap config)
   at AutoMapper.ProfileMap.TypeDetailsFactory(Type type)
   at AutoMapper.Internal.LockingConcurrentDictionary`2.<>c__DisplayClass2_1.<.ctor>b__1()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at AutoMapper.Internal.LockingConcurrentDictionary`2.GetOrAdd(TKey key)
   at AutoMapper.ProfileMap.CreateTypeDetails(Type type)
   at AutoMapper.Configuration.Conventions.NameSplitMember.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers, IMemberConfiguration parent, Boolean isReverseMap)
   at AutoMapper.Configuration.Conventions.MemberConfiguration.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers, Boolean isReverseMap)
   at AutoMapper.ProfileMap.MapDestinationPropertyToSource(TypeDetails sourceTypeInfo, Type destType, Type destMemberType, String destMemberInfo, LinkedList`1 members, Boolean reverseNamingConventions)
   at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options, Boolean isReverseMap)
   at AutoMapper.ProfileMap.BuildTypeMap(IConfigurationProvider configurationProvider, ITypeMapConfiguration config)
   at AutoMapper.ProfileMap.Register(IConfigurationProvider configurationProvider)
   at AutoMapper.MapperConfiguration.Seal()
   at AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression)
   at AutoMapper.MapperConfiguration..ctor(Action`1 configure)
   at GitReleaseManager.Core.AutoMapperConfiguration.Configure() in /_/src/GitReleaseManager.Core/AutoMapperConfiguration.cs:line 13
   at GitReleaseManager.Cli.Program.RegisterServices(BaseSubOptions options) in /_/src/GitReleaseManager.Cli/Program.cs:line 78
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at GitReleaseManager.Cli.Program.Main(String[] args) in /_/src/GitReleaseManager.Cli/Program.cs:line 34
@SimonCropp
Copy link
Contributor Author

seems an update to the current of automapper should fix it AutoMapper/AutoMapper#4163

@gep13
Copy link
Member

gep13 commented Sep 22, 2023

@SimonCropp hmm, this is an interesting one...

We recently ignored a Dependabot PR to update AutoMapper:

#509

Since it isn't compatible with the current projects target frameworks.

I would need to dig in and figure out exactly what would be required to get that update in.

What exactly is it that it is falling up on?

@pleonex
Copy link

pleonex commented Oct 8, 2023

Same happening for me. It's failing to export the release notes (with and without tagName). Downgrading to 0.14.0 works.

@Jericho
Copy link
Contributor

Jericho commented Nov 6, 2023

I just experienced this issue as well. If I understand correctly, it seems there's an issue in the older version of AutoMapper we are referencing when used under .net7. The obvious solution is to upgrade to a more recent version of AutoMapper but they dropped support for netstandard2.0, which means that we would need to change <TargetFrameworks>netstandard2.0</TargetFrameworks> in GitReleaseManager.Core.csproj to <TargetFrameworks>netstandard2.1</TargetFrameworks>.

Another possibility could be to pin the .NET SDK to 6.x.x. I haven't tried this because I no longer have .NET SDK version 6 installed on my laptop.

To be clear: I only experience this on my laptop, not on the CI environment. I suspect the difference is that .NET 6 is not on my machine while it probably is installed in the CI environment.

@Jericho
Copy link
Contributor

Jericho commented Nov 7, 2023

I upgraded AutoMapper to the latest release and this had the following consequences:

  • I had to upgrade netstandard2.0 to netstandard2.1 in GitReleaseManager.Core.csproj which has the side effect of dropping compatibility with net48
  • The fact that GRM Core is no longer compatible with net48 means that I had to drop net48 in GitReleaseManager.Cli.csproj
  • I also had to drop net48 from the three testing projects

If loosing compatibility with net48 is not desirable, maybe we could look into my previous suggestion of pinning the .NET SDK to version 6. However, I don't see this as a long term solution because sooner of later we'll want to upgrade the SDK. Otherwise, maybe we could look into switching to an alternative mapping nuget package?

@gep13 I'm more than willing to investigate further and to submit a PR but I need some direction. Do you think dropping net48 is acceptable? If not, should I investigate pinning the SDK or should I search for an alternative to AutoMapper?

@Jericho
Copy link
Contributor

Jericho commented Nov 7, 2023

I went ahead and installed .NET 6 SDK on my machine and to my surprise the problem went away! I didn't even have to pin the SDK or change anything else. It seems like the root of the problem is that only .NET 7 was installed on my machine.

Here's what dotnet --info says:
image

Notice that 6.0.416 is now listed, that wasn't the case until earlier this morning.

As far as I'm concerned, this is an acceptable solution which allows me to move forward. I don't think any other changes are necessary.

@mkevenaar
Copy link

@gep13
Copy link
Member

gep13 commented Nov 10, 2023

Myself and @AdmiringWorm met today to discuss this, and what we thought would be the course of action. We have come up with a plan that we think will work, but we are also happy to take some feedback if folks think there are other things to discuss...

Long story short, we still want to have both a .NET Global Tool version, and a Chocolatey package version of GitReleaseManager. Given the requirement to update to the latest version of AutoMapper, this means that we lose support for .NET Standard 2.0, and instead need to use at least .NET Standard 2.1. If we do that, we can no longer use .NET Framework 4.8. And it we do that, we lose the ability to create an application that will work directly on Windows via the Chocolatey package.

So, having said all of that, here is the plan...

Switch the projects to target the following:

Projet Target Frameworks
Cli net6.0
Tool net6.0 and net7.0
Core net6.0 and net7.0

The Cli project will then switch to creating a Standalone Application, which will. then be bundled into the Chocolatey Package, and be deployed from there. To allow this to work as expected, the nuspec file will be updated to remove the dependency on the .NET 4.8 package.

The release notes will need to be updated to make this change clear, to ensure that everyone is aware of the change.

@gep13 gep13 added this to the 0.16.0 milestone Nov 10, 2023
@gep13 gep13 changed the title crash: violates the constraint of type GitReleaseManager doesn't run under .NET 7.0 Nov 10, 2023
@Jericho
Copy link
Contributor

Jericho commented Nov 12, 2023

Quick update: I'm experiencing this problem again on my machine despite the fact that installing .NET6 seemed to have fixed the problem a few days ago.

This highlights the fact that the only long term solution is what is being implemented in PR #545.

@gep13 gep13 added Breaking Change and removed Bug labels Nov 14, 2023
@gep13 gep13 changed the title GitReleaseManager doesn't run under .NET 7.0 GitReleaseManager doesn't run under .NET 7.0 - need to remove support for .NET 4.8 Nov 14, 2023
@gittools-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.16.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

6 participants