Metalama icon indicating copy to clipboard operation
Metalama copied to clipboard

Feature Request: Report potential accessibility issues in run-time code referred to in templates

Open WhitWaldo opened this issue 11 months ago • 2 comments

For testing purposes, I've got my aspect and its related classes in one project, some dummy entities in another project and my unit tests in a third project. I was trying to work through some build errors I'd seen on my dummy entities after setting the configuration manager to LamaDebug and noticed that I have a bunch of errors along the lines of "LAMA06' Error CS0122 in code generated by aspect 'MyAspect': 'XYZ' is inaccessible due to its protection level".

After poking at this a bit, it's spot-on - because my entities are in a separate project, they don't have access to methods marked as internal in my aspects project.

I would propose one of two paths forward. If a project containing a Metalama project points to a run-time field, property or method marked as anything other than public as part of building out whatever it's doing:

  1. It throws a build error indicating that because of the protection level applied to whatever it's named, this will result in downstream runtime errors
  2. It automatically change the visibility of the offending field, property or method to public so that at run-time in the other project, it will be available and show a build warning indicating that this was done

Thank you for the consideration!

WhitWaldo avatar Jul 31 '23 17:07 WhitWaldo

Hello @WhitWaldo, thank you for submitting this issue. We will try to get back to you as soon as possible. Note to the PostSharp team, this ticket is being tracked in our dashboard under ID TP-33603.

PostSharpBot avatar Jul 31 '23 17:07 PostSharpBot

I like your first proposal best because automatically changing stuff is generally a recipe for mess and failure.

gfraiteur avatar Aug 01 '23 08:08 gfraiteur