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

Formatting crashes on C# assembly with event #271

Closed
Vidarls opened this issue Mar 20, 2015 · 10 comments
Closed

Formatting crashes on C# assembly with event #271

Vidarls opened this issue Mar 20, 2015 · 10 comments
Labels

Comments

@Vidarls
Copy link
Contributor

Vidarls commented Mar 20, 2015

The following c# code crashes Fsharp.formatting:

I believe @matthid mentioned some issues with events during his work on improving C# support earlier..

/// <summary>
/// Event triggered when WorklistText is required
/// </summary>
[ComVisible(false)]
public delegate void WorklistTextRequested(int medicalRecordId, string accessionNo, 
  int templateId, string specificationCode, string specificationText, string aeTitle);

public event WorklistTextRequested OnWorklistTextRequested;

Error:

Microsoft.FSharp.Compiler.ErrorLogger+ReportedError: The event 'OnWorklistTextRequested' has a non-standard type. If this event is declared in another CLI language, you may need to access this event using the explicit add_OnWorklistTextRequested and remove_OnWorklistTextRequested methods for the event. If this event is declared in F#, make the type of the event an instantiation of either 'IDelegateEvent<>' or 'IEvent<,_>'.

stack trace:

ved Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Error[b](ErrorLogger x, Exception exn) i C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\ErrorLogger.fs:linje 321
   ved Microsoft.FSharp.Compiler.Infos.ArgsTypOfEventInfo(InfoReader infoReader, range m, AccessorDomain ad, EventInfo einfo) i C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\infos.fs:linje 3805
   ved Microsoft.FSharp.Compiler.Infos.PropTypOfEventInfo(InfoReader infoReader, range m, AccessorDomain ad, EventInfo einfo) i C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\infos.fs:linje 3816
   ved Microsoft.FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue.get_ReturnParameter() i C:\GitHub\fsharp\FSharp.Compiler.Service\src\fsharp\vs\Symbols.fs:linje 1441
   ved FSharp.MetadataFormat.ValueReader.readMemberOrVal(ReadingContext ctx, FSharpMemberOrFunctionOrValue v) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 343
   ved FSharp.MetadataFormat.Reader.tryReadMember@777.Invoke(String cat, IDictionary`2 _arg1, Comment comment) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 778
   ved FSharp.MetadataFormat.Reader.readCommentsInto[a](ReadingContext ctx, String xmlDoc, FSharpFunc`2 f) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 763
   ved FSharp.MetadataFormat.Reader.tryReadMember(ReadingContext ctx, MemberKind kind, FSharpMemberOrFunctionOrValue memb) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 777
   ved FSharp.MetadataFormat.Reader.readAllMembers@784.Invoke(FSharpMemberOrFunctionOrValue memb) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 784
   ved Microsoft.FSharp.Collections.IEnumerator.choose@163.System-Collections-IEnumerator-MoveNext()
   ved Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   ved FSharp.MetadataFormat.Reader.readType@858.Invoke(String cat, IDictionary`2 cmds, Comment comment) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 896
   ved FSharp.MetadataFormat.Reader.readCommentsInto[a](ReadingContext ctx, String xmlDoc, FSharpFunc`2 f) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 763
   ved FSharp.MetadataFormat.Reader.readType(ReadingContext ctx, FSharpEntity typ) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 858
   ved FSharp.MetadataFormat.Reader.readModulesAndTypes@851-2.Invoke(ReadingContext ctx, FSharpEntity typ) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 851
   ved Microsoft.FSharp.Collections.IEnumerator.choose@163.System-Collections-IEnumerator-MoveNext()
   ved Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   ved FSharp.MetadataFormat.Reader.readModulesAndTypes(ReadingContext ctx, IEnumerable`1 entities) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 852
   ved FSharp.MetadataFormat.Reader.readNamespace(ReadingContext ctx, String ns, IEnumerable`1 entities) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 930
   ved FSharp.MetadataFormat.Reader.readAssembly@955-1.Invoke(Tuple`2 tupledArg) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 955
   ved Microsoft.FSharp.Collections.IEnumerator.map@116.DoMoveNext(b& )
   ved Microsoft.FSharp.Collections.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   ved Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   ved FSharp.MetadataFormat.Reader.readAssembly(FSharpAssembly assembly, Boolean publicOnly, String xmlFile, FSharpOption`1 sourceFolderRepo, FSharpFunc`2 urlRangeHighlight, Boolean markDownComments, IUrlHolder urlMap) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 958
   ved <StartupCode$FSharp-MetadataFormat>.$Main.assemblies@1084-3.GenerateNext(IEnumerable`1& next) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 0
   ved Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   ved Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   ved Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   ved FSharp.MetadataFormat.MetadataFormat.Generate(FSharpList`1 dllFiles, String outDir, IEnumerable`1 layoutRoots, FSharpOption`1 parameters, FSharpOption`1 namespaceTemplate, FSharpOption`1 moduleTemplate, FSharpOption`1 typeTemplate, FSharpOption`1 xmlFile, FSharpOption`1 sourceRepo, FSharpOption`1 sourceFolder, FSharpOption`1 publicOnly, FSharpOption`1 libDirs, FSharpOption`1 otherFlags, FSharpOption`1 markDownComments, FSharpOption`1 urlRangeHighlight, FSharpOption`1 assemblyReferences) i c:\Tomas\Public\FSharp.Formatting\src\FSharp.MetadataFormat\Main.fs:linje 1084
@matthid
Copy link
Member

matthid commented Mar 23, 2015

I never saw this (maybe because I don't do much C# with events). For one-time events I use task (which is safer in multi thread environments) and IObservable otherwise.

For the exception: This looks like a FCS bug/limitation (I have a FCS only repro here).
@dsyme Why are we not allowed to call ReturnParameter on C# events? Should we work around that or open an issue on FCS?

@Vidarls
Copy link
Contributor Author

Vidarls commented Mar 23, 2015

This particular case is COM (vb6) -> .net interop and as such I have to use events,

@matthid
Copy link
Member

matthid commented Mar 23, 2015

In this case I don't see any "quick" fix, you can try to work around this in F# Formatting by checking for an event and don't calling the ReturnParameter property. Or try to do the proper fix in FCS if dsyme agrees that this is a bug (I have linked the testcase above).

@matthid
Copy link
Member

matthid commented Sep 20, 2015

The problem was mentioned here before: #208 (comment)

@matthid
Copy link
Member

matthid commented Sep 20, 2015

As a workaround: Adding [omit] works.

/// <summary>
/// [omit]
/// </summary>

matthid added a commit that referenced this issue Sep 20, 2015
… a single member and write an error, workaround for #271 (and future FCS bugs).
@matthid
Copy link
Member

matthid commented Sep 20, 2015

Alternatively you can try to use 2.11.0-alpha2 which has improved error handling and can recover from this. Can you report this to FCS to fix the root issue? FSF will still print out the error message and the event will be missing from the generated documentation.

@Vidarls
Copy link
Contributor Author

Vidarls commented Sep 25, 2015

Thanks, I'm trying my luck with FCS.

Do you know of any known issues in the alpha releases of FSF, or should I not expect much trouble updating?

@matthid
Copy link
Member

matthid commented Sep 25, 2015

There are no known issues. Its just a quick way for me to make and test a release even before @tpetricek had some time to review, comment or discuss the changes.

@dsyme
Copy link
Contributor

dsyme commented Sep 30, 2015

See comment about events here: #208 (comment)

@matthid
Copy link
Member

matthid commented Jan 14, 2016

I think this can be closed now.

@matthid matthid closed this as completed Jan 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants