The ruling could force affordable housing developers to sell their properties to their nonprofit partners.