question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with public structs

See original GitHub issue

Hi,

We have some public structs declared in our project that is using MrAdvice and it seems the Assembly doesn’t have those struct anymore when we build it. I have this struct: public struct ExempleKeyPair<TItemId, TItem> with these properties: public readonly TItemId ItemId; public readonly TItem Item;

and this constructor: public ExempleKeyPair(TItemId itemId, TItem item) { ItemId = itemId; Item = item; }

When I do this call : new ExempleKeyPair<int, string>(itemId, item) I get this error when my advice is in the project System.TypeLoadException: Could not load type 'Application.BLL.Common.ExempleKeyPair``2' from assembly If I put [ExcludeAdvices("*")] on the struct it works. Also, if I change the type to a class it works. So, there seems to be a problem with structs. I couldn’t use ExcludePointcutAttribute to filter the struct. I’m currently using the version 2.8.5 but I also tried with 2.8.4.

I could put [ExcludeAdvices("*")] on every structs but I don’t want to modify all structs for the code to work. Could you tell me if there’s another way of if there could be a fix for that?

Thanks,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rhap06commented, Sep 6, 2019

Hi!

Sorry for the delay, yes I tried it and it works. It only happens when you try to have a generic struct, like a key pair.

0reactions
picrapcommented, Sep 10, 2019

Thanks for reporting the issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

C # Struct private/public error
Just as the compiler is telling you, you're trying to perform an operation that needs a static variable. You either want to create...
Read more >
solidity - public struct showing stack overflow error
if I remove the public keyword from User public user; then works fine or I maintain 9 data in struct then works fine....
Read more >
Structs with public fields are brittle
Any struct with only public fields or no fields at all can be pattern matched and instantiated wherever it is visible.
Read more >
Beginners question: pub structs : r/rust
A pub struct without a single pub field is an opaque type: users of your library can receive them, pass them back, maybe...
Read more >
Structure types - C# reference
Every struct has a public parameterless constructor. If you write a parameterless constructor, it must be public. If a struct declares any field ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found