What ways to attach a library to a form? I created a custom form and I use a js library on it. I attached my JS in my template file but in a first time, I tried to attach it directly on my form with

$form['#attached']['library'][] = "mymodule/mylibrary" 


like in D7 but it doesn't work.

I found none references to attach library directly to a form and no references to the "#attached" property so I suppose it has been remove.

My library works fine in the twig template file.

But in the case I don't used a custom template or I use various templates for various cases, can I attach my library directly to my form without pass by a hook function or must I pass necessary by the template file, a hook_preprocess or a hook_page_attachment?
Like explain by Clive, add libraries directly in the form via '#attached' parameter works. The mistake in my case was to don't send my form properly to my template file. See  Send a form to twig template