0

I've got a few .Net 6 cs files that don't recognize a using reference if I put it before the namespace, but does recognize it if I put it after the namespace.

The Hl7.Fhir.Model library and ServiceRequest class are not recognized here:

using Core.Features;
using Hl7.Fhir.Model;
using Infrastructure.Data.AgingAndDisability.Repositories;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace Core.AgingAndDisability.Features.ServiceRequest;

public class ServiceRequestCreator : ICreator<ServiceRequest>
...snip...

Everything works fine when I put the usings after the namespace:

namespace Core.AgingAndDisability.Features.ServiceRequest;

using Core.Features;
using Hl7.Fhir.Model;
using Infrastructure.Data.AgingAndDisability.Repositories;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

public class ServiceRequestCreator : ICreator<ServiceRequest>
...snip...

In other cs files, the Hl7.Fhir.Model reference works fine in a using that comes before the namespace. I haven't seen this with any other library references. Hl7.Fhir.Model comes from this package

Any insight as to what's affecting the ordering here?

scottctr
  • 683
  • 2
  • 6
  • 19
  • @Progman, I don't think so. The issue here isn't that it's matching the wrong implementation of ServiceRequest. For some reason, it's just not picking up the library reference outside of the using. I now suspect part of the issue is that it's picking up the ServiceRequest in the namespace before the class definition in the Hl7 library though. – scottctr Apr 24 '22 at 22:00
  • @Progman, sorry, you're right. This is the scenario that Ben Gardner points out in his answer. – scottctr Apr 24 '22 at 22:10

0 Answers0