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

Add support for .asmref files #1406

Closed
citizenmatt opened this issue Nov 13, 2019 · 10 comments · Fixed by #2252
Closed

Add support for .asmref files #1406

citizenmatt opened this issue Nov 13, 2019 · 10 comments · Fixed by #2252
Assignees
Milestone

Comments

@citizenmatt
Copy link
Member

citizenmatt commented Nov 13, 2019

Unity 2019.2 added .asmref files - Assembly Definition References Files.

From the release notes to 2019.2.0a6:

Scripting: Added support for Assembly Definition Reference Files (asmref). These allow for adding additional source code directories to an existing Assembly Definition File (asmdef).

There doesn't seem to be much documentation:

You can use Assembly Definition Reference Assets to add additional folders to an existing Assembly Definition asset.

Add support, e.g. syntax highlighting, JSON schema, and whatever else is needed. Also look at how this affects showing the project name in the Unity Explorer tree view (#1398)

@SugoiDev
Copy link

SugoiDev commented Nov 14, 2019

As requested in #1398 (comment), this is a sample asmref file. For now, they are incredibly simple:
Here's the editor
image

There file content is the following

  1. When not using GUID
{
    "reference": "Vendor"
}
  1. When using GUID
{
    "reference": "GUID:679b1ad5ea99ee144828e78799109596"
}

@CanBaycay
Copy link

I would really love to see .asmref support happening in Rider.

Unity.Mathematics library is full of partial classes that makes it really easy to be extensible just by putting an Assembly Definition Reference inside an external folder. Seems like Unity is happy with that approach but Rider goes crazy with asmref being around and does not even see the symbols in original asmdef for some reason.

For starters, at least just a basic support to prevent these errors would be great.

Here is a simple example project:

https://gitlab.com/canbaycay/RiderAsmrefSupportExample

@SugoiDev
Copy link

Oh? I thought it worked fine with asmrefs, just didn't have proper support to create them, but it seems it's not working properly when being used with packages?

I use them extensively on my current project, and never noticed anything strange in Rider. But, I only use them for "Editor" folders. Never used them to extend a package. That's super neat and I hadn't thought about it at all. (thanks!)

@SugoiDev
Copy link

Or maybe Rider breaks when used with partial classes in particular?
I mean, the actual projects should have no knowledge of the "asmref" itself. They'll behave as if the files were included in them normally, from what I know.

Did you have trouble with using an asmref but not using a partial class? Just doing something with something "internal" on a package, for example.

I'll see if I can make time to do a quick test on this.

@van800
Copy link
Contributor

van800 commented Feb 24, 2020

@CanBaycay Sorry for delay. I have just downloaded your example, open with Unity 2019.3.0f5 with Rider package 1.2.1 and Rider 2019.3.3 and it is all green, except slow SWEA (https://youtrack.jetbrains.com/issue/RIDER-22945). You may try to build your solution in Rider, and if it builds, but Rider is still showing errors - then try the last resort File->Invalidate caches and Restart.

@diomich
Copy link

diomich commented May 31, 2021

@van800 I have the same issue with both my project and sample project mentioned above. Rider just does not see the original assembly. Anyway, Unity3d can compile this code without errors. Tried both build the solution and "invalidate caches and restart" Didn't help.

Unity3d version: 2019.4.26f1
Rider version: 2020.2.5

@van800
Copy link
Contributor

van800 commented May 31, 2021

@diomich try to update Rider package to latest (3.0.7)

@van800 van800 closed this as completed May 31, 2021
@citizenmatt
Copy link
Member Author

I'm going to reopen this. We don't need to do anything to support projects that contain .asmref - the project files are correctly generated, etc. But we also don't provide syntax highlighting or any support for the references node (completion, navigation, find usages, etc.)

@citizenmatt citizenmatt reopened this Sep 15, 2021
@citizenmatt
Copy link
Member Author

We should also look at what happens with non-user code in projects generated from .asmref files. For example, if I want to extend Unity.Mathematics with a .asmref, then the generated project will include my user code, and also the non-user code from the Unity Mathematics package. This non-user code should be treated as read only, not analysed, etc.

@citizenmatt citizenmatt self-assigned this Jan 25, 2022
@citizenmatt citizenmatt added this to the Rider 2022.1 milestone Jan 25, 2022
@citizenmatt citizenmatt linked a pull request Jan 25, 2022 that will close this issue
5 tasks
@citizenmatt
Copy link
Member Author

Closing this. #2252 adds support for .asmref files - syntax highlighting, JSON schema validation + completion, completion for the reference node, ctrl+click navigation and Find Usages support for the reference, GUID reference tooltip and inlay, and the reference will be updated when an assembly definition is renamed.

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 a pull request may close this issue.

5 participants