Closed MohadKamil closed 6 years ago
Hi
Thanks for the feedback. I'm still working on VS 15.5.0 so I haven't had chance to test it on newer version. Could you provide a sample code that cause this exception of code fix?
I have a lot of null reference exceptions too. VS 15.6.4 and I get a lot of these errors when creating a response :
using System.Collections.Generic;
using System.Runtime.Serialization;
using Nms.Client.Abf.Shared.Contracts.Detailing.Entities;
namespace Nms.Client.Abf.Shared.Contracts.Detailing
{
[DataContract]
public class GetDetailingStatusesResponse : BaseAbfResponse
{
public GetDetailingStatusesResponse()
{
}
public GetDetailingStatusesResponse(List<StatusEntity> statuses)
{
Statuses = statuses;
}
public List<StatusEntity> Statuses { get; }
}
}
I've installed VS 15.6.5 but I'm unable to reproduce this problem. I would like to help but I need an example code that cause this issue. Maybe there was an issue with roslyn and VS 15.6.4 and 15.6.5 update fixed that.
There a repro with a .Net Standard class library, didn't test with a classic class library.
using System.Collections.Generic;
namespace ClassLibrary5
{
public class GetReportsResponse : BaseAbfResponse
{
public GetReportsResponse(List<string> reports)
{
}
}
public abstract class BaseAbfResponse
{
public bool IsSuccessful => true;
}
}
@OmiCron07 thanks for the example code which helped me to reproduce the issue. I've prepared the fix but I'm unable to test it because of the issue https://github.com/dotnet/roslyn/issues/25962 This also prevents me from releasing fix for #13
Does the version 15.6.6 fix the problem? There are no release notes yet.
The problem seems to persist in 15.6.6 (unlike #13)
Hi, thanks for the useful extension by the way.
The extension keeps crashing with a null reference exception, this started right after updating visual studio to version 15.6.4, prior versions of visual studio worked just fine with the extension.
Stack trace: System.NullReferenceException : Object reference not set to an instance of an object. at MappingGenerator.SymbolHelper.IsReadonlyProperty(IPropertySymbol property) at MappingGenerator.MappingGenerator.CanBeSet(IPropertySymbol targetProperty,SyntaxNode globbalTargetAccessor,Boolean isConstructorContext) at lMappingGenerator.MappingGenerator.d__4.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator)
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.PreviewChangesSuggestedAction.CreateAsync()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.GetPreviewChangesFlavor()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.CreateAllFlavors()
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T]()
2.MoveNext() at Microsoft.CodeAnalysis.SyntaxList
1.CreateNode(IEnumerable1 nodes) at Microsoft.CodeAnalysis.CSharp.CodeGeneration.CSharpSyntaxGenerator.AsStatementList(IEnumerable
1 nodes) at Microsoft.CodeAnalysis.CSharp.CodeGeneration.CSharpSyntaxGenerator.CreateBlock(IEnumerable1 statements) at Microsoft.CodeAnalysis.CSharp.CodeGeneration.CSharpSyntaxGenerator.MethodDeclaration(String name,IEnumerable
1 parameters,IEnumerable1 typeParameters,SyntaxNode returnType,Accessibility accessibility,DeclarationModifiers modifiers,IEnumerable
1 statements) at Microsoft.CodeAnalysis.Editing.SyntaxGenerator.MethodDeclaration(IMethodSymbol method,String name,IEnumerable`1 statements) at async MappingGenerator.MappingGeneratorCodeFixProvider.GenerateMappingMethodBody(