Following up on your comment:
I am confused about the scope of anonymous types
First let's clearly define "scope". The scope of a type is defined as the region of program text in which the type may be referred to by its unqualified name.
With that definition it is obvious what the scope of an anonymous type is. There is no region of program text in which the anonymous type may be referred to by its name because it does not have a name. Anonymous types don't have scope at all. You don't have to worry about its scope; it has no scope.
The fields of an anonymous type also have no scope, but for a different reason. Fields of an anonymous type have names, but it is never legal to refer to them by their unqualified names, so the scope of each field is empty.
I am not sure what will be visibility of this type within a method or class scope.
Again, let's clearly define our terms. The scope of an entity may include entities which define declaration spaces. Those declaration spaces may declare entities that have the same name as the original entity. Those entities have their own scopes, which may nest inside of the scope of the original entity.
In this situation, a more-nested entity may "hide" a less-nested entity. An entity which is not hidden in this manner is said to be "visible" at a particular textual location.
An anonymous type does not have a scope, and it obviously cannot be hidden by name because it does not have a name. Asking whether an anonymous type is "visible" or not is not a sensible thing to do; "visibility" only makes sense for things that have names.
My thinking is that given that this type is not declared anywhere, how can the compiler figure out which type I am talking about?
The compiler makes a note of every textual location in which you use an anonymous type within a program. If any two of those locations refer to anonymous types that have the same field names, the same field types and the fields come in the same order then those two locations are treated as usages of the same anonymous type.
The compiler can then emit one type for each of the unique anonymous types you used in your assembly. The details of how it does so are fascinating (*). I suggest that you poke around your assembly with ILDASM to see how we do it if you are interested.
If you make "the same" anonymous type -- same names, types and in the same order -- in two different assemblies then the anonymous types will not be treated as the same type. Anonymous types are not designed to be used across assembly boundaries.
(*) To me.