Skip to content

Conversation

@jetersen
Copy link
Contributor

@jetersen jetersen commented Jan 3, 2020

No description provided.

@jetersen
Copy link
Contributor Author

jetersen commented Jan 3, 2020

I much have a twitchy finger 😭

@jetersen jetersen closed this Jan 3, 2020
@jetersen jetersen reopened this Jan 3, 2020
@jetersen jetersen closed this Jan 3, 2020
@jetersen jetersen reopened this Jan 3, 2020

public override string ToString()
{
var builder = new StringBuilder();
Copy link
Contributor Author

@jetersen jetersen Jan 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer I moved this to a JsonBuilder?
So it could be reused by #2017 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. How would a generic JsonBuilder look like? If you have a suggestion, please add it to the PR.

@jetersen
Copy link
Contributor Author

jetersen commented Jan 3, 2020

Not sure why build is failing

@jetersen
Copy link
Contributor Author

jetersen commented Jan 6, 2020

🤷‍♂ Not sure what makes this minor change explode the entire testsuite.

@jetersen
Copy link
Contributor Author

jetersen commented Jan 6, 2020

Would love to add an generic JsonBuilder but it does not help when CI is utterly bogus 😭

@asbjornu
Copy link
Member

asbjornu commented Jan 7, 2020

Good question, @Casz. Seems like there's some cleanup job that fails.

@gep13
Copy link
Member

gep13 commented Jan 7, 2020

Not sure why this would be a problem, but on the AppVeyor build there is this:

InnerException:	System.Xml.XmlException: The token 'false' was expected but found 'fix-r'.

It is a little coincidental that the branch name for the PR starts with fix as well. Could this be part of the problem? @asbjornu @arturcic

@asbjornu
Copy link
Member

asbjornu commented Jan 7, 2020

That sounds both crazy and plausible at the same time, @gep13. Why would a branch name cause an XmlException, I wonder?

@jetersen
Copy link
Contributor Author

Trying to run tests locally I get:

System.ComponentModel.Win32Exception : The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(String fileName, String arguments)
   at Shouldly.Configuration.DiffTool.Open(String receivedPath, String approvedPath, Boolean approvedExists) in C:\projects\shouldly\src\Shouldly\Configuration\DiffTool.cs:line 59
   at Shouldly.ShouldMatchApprovedTestExtensions.ShouldMatchApproved(String actual, Func`1 customMessage, Action`1 configureOptions) in C:\projects\shouldly\src\Shouldly\ShouldlyExtensionMethods\ShouldMatchApprovedTestExtensions.cs:line 79
   at Shouldly.ShouldMatchApprovedTestExtensions.ShouldMatchApproved(String actual, Action`1 configureOptions) in C:\projects\shouldly\src\Shouldly\ShouldlyExtensionMethods\ShouldMatchApprovedTestExtensions.cs:line 25
   at GitVersionCore.Tests.JsonVersionBuilderTests.Json() in C:\git\code\GitVersion\src\GitVersionCore.Tests\JsonVersionBuilderTests.cs:line 41

@jetersen
Copy link
Contributor Author

jetersen commented Jan 21, 2020

Think I'll recreate the PR to see if it fixes the odd xml exception

@jetersen jetersen closed this Jan 21, 2020
@jetersen jetersen reopened this Jan 21, 2020
@jetersen
Copy link
Contributor Author

Think I figured it out, it related to https://github.com/cake-build/cake/tree/develop/src/Cake.Common/Tools/GitVersion basically this is a breaking change.

@gep13
Copy link
Member

gep13 commented Jan 21, 2020

@Casz just so I am clear... are you saying that we would need to update the Cake aliases for GitVersion to account for the change that you are making here? I haven't been following this issue/PR very closely, but can you give me a recap of the change that is being made here, and what would need to change in Cake to make this happen?

@jetersen
Copy link
Contributor Author

The idea was to Remove the JSON output formatter and override the to string method

@gep13
Copy link
Member

gep13 commented Jan 21, 2020

@Casz said...
The idea was to Remove the JSON output formatter and override the to string method

That part I understand, but why is this a breaking change?

What specifically needs to be addressed in the Cake aliases to account for this?

@jetersen
Copy link
Contributor Author

Not sure I haven't had a chance to dig into the code. I just see it's going through the GitVersionAlias and complains about the JSON Output:

See:

StackTrace:        at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(XmlDictionaryReader reader)
   at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(Stream stream)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
   at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings) in C:\projects\cake\src\Cake.Common\Tools\GitVersion\GitVersionRunner.cs:line 65
   at Cake.Common.Tools.GitVersion.GitVersionAliases.GitVersion(ICakeContext context, GitVersionSettings settings) in C:\projects\cake\src\Cake.Common\Tools\GitVersion\GitVersionAliases.cs:line 121
   at Submission#0.GitVersion(GitVersionSettings settings)
   at Submission#0.GetVersion(BuildParameters parameters)
   at Submission#0.<<Initialize>>b__0_83(ISetupContext context)
        Message:        There was an error deserializing the object of type Cake.Common.Tools.GitVersion.GitVersionInternal. The token 'false' was expected but found 'fix-r'.
        Data:   [  ]
        InnerException: System.Xml.XmlException: The token 'false' was expected but found 'fix-r'.
   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
   at System.Runtime.Serialization.Json.XmlJsonReader.Read()
   at System.Xml.XmlBaseReader.ReadElementContentAsString()
   at ReadGitVersionFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )

Specifically: ReadGitVersionFromJson and Cake.Common.Tools.GitVersion.GitVersionRunner.Run

@gep13
Copy link
Member

gep13 commented Jan 21, 2020

Do we have a comparison of what is output before and after this change?

@jetersen
Copy link
Contributor Author

The issue is located in the GitVersionInternal method as I have changed the ToString method.

https://github.com/cake-build/cake/blob/7e8a8013a43c4bd5b15e16eea3c6347ffc572f35/src/Cake.Common/Tools/GitVersion/GitVersionInternal.cs#L202-L206

@jetersen
Copy link
Contributor Author

Let me try and revert the ToString method change.

@jetersen
Copy link
Contributor Author

No... not related to my changes.

I reset my branch to upstream/master and still got the same error.

@gep13
Copy link
Member

gep13 commented Jan 21, 2020

@Casz ok, can we go back to my suggestion regarding the branch name? Can you submit your PR from a different branch name, so that we can rule that out. And if that is the problem, then we have a bug that needs to be addressed.

@jetersen
Copy link
Contributor Author

I tried see #2058

@jetersen
Copy link
Contributor Author

but it's also failing locally when I checkout master branch

@jetersen
Copy link
Contributor Author

jetersen commented Jan 21, 2020

FYI!!!! This is also failing in CI on Master branch but we are apparently ignoring it:

https://ci.appveyor.com/project/GitTools/gitversion/builds/30222649#L138

@jetersen
Copy link
Contributor Author

git checkout -b test
./build.ps1 -script build.cake -target Default

Results in

Resolving assembly System.Private.DataContractSerialization.resources, Version=4.1.5.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a
Exception while resolving assembly System.Private.DataContractSerialization.resources: Could not load file or assembly 'System.Private.DataContractSerialization.resources, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Resolving assembly System.Private.Xml.resources, Version=4.0.2.0, Culture=en-US, PublicKeyToken=cc7b13ffcd2ddd51
Exception while resolving assembly System.Private.Xml.resources: Could not load file or assembly 'System.Private.Xml.resources, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
        TargetSite:     System.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)
        StackTrace:        at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(XmlDictionaryReader reader)
   at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.ReadObject(Stream stream)
   at System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(Stream stream)
   at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings) in C:\projects\cake\src\Cake.Common\Tools\GitVersion\GitVersionRunner.cs:line 65
   at Cake.Common.Tools.GitVersion.GitVersionAliases.GitVersion(ICakeContext context, GitVersionSettings settings) in C:\projects\cake\src\Cake.Common\Tools\GitVersion\GitVersionAliases.cs:line 121
   at Submission#0.GitVersion(GitVersionSettings settings)
   at Submission#0.GetVersion(BuildParameters parameters)
   at Submission#0.<<Initialize>>b__0_83(ISetupContext context)
        Message:        There was an error deserializing the object of type Cake.Common.Tools.GitVersion.GitVersionInternal. The token 'true' was expected but found 'test'.
        Data:   [  ]
        InnerException: System.Xml.XmlException: The token 'true' was expected but found 'test'.
   at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
   at System.Runtime.Serialization.Json.XmlJsonReader.Read()
   at System.Xml.XmlBaseReader.ReadElementContentAsString()
   at ReadGitVersionFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString[] )
   at System.Runtime.Serialization.Json.JsonClassDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context)
   at System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
   at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)
   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
   at System.Runtime.Serialization.Json.DataContractJsonSerializerImpl.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)
   at System.Runtime.Serialization.XmlObjectSerializer.InternalReadObject(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
        HelpLink:
        Source: System.Private.DataContractSerialization
        HResult:        -2146233076

@jetersen
Copy link
Contributor Author

Okay, I recloned the repo, and now I am not seeing any failures locally 🤔

@jetersen
Copy link
Contributor Author

Hmm locally it works now, I need to prune or recreate my repo somehow...

@jetersen jetersen closed this Jan 21, 2020
@jetersen jetersen deleted the fix/remove-json-output-formatter branch January 21, 2020 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants