func (v {{.Name}}Value) To{{.AssocExtType.ToPascalCase}}(ctx context.Context) ({{.AssocExtType.Type}}, diag.Diagnostics) {
var diags diag.Diagnostics

if v.IsNull() {
return nil, diags
}

if v.IsUnknown() {
diags.Append(diag.NewErrorDiagnostic(
"{{.Name}}Value Value Is Unknown",
`"{{.Name}}Value" is unknown.`,
))

return nil, diags
}

attributes := v.Attributes()

{{- range $key, $value := .AttrTypesToFuncs}}

{{$key}}Attribute, ok := attributes["{{$key}}"].({{$value.AttrValue}})

if !ok {
diags.Append(diag.NewErrorDiagnostic(
"{{$.Name}}Value {{$key}} is unexpected type",
fmt.Sprintf(`"{{$.Name}}Value" {{$key}} is type of %T".`, attributes["{{$key}}"]),
))
}
{{- end}}

if diags.HasError() {
return nil, diags
}

{{.AssocExtType.ToCamelCase}} := {{.AssocExtType.TypeReference}} {
{{- range $key, $value := .AttrTypesToFuncs}}
{{$key.ToPascalCase}}: {{$key}}Attribute.{{$value.ToFunc}}(),
{{- end}}
}

return &{{.AssocExtType.ToCamelCase}}, diags
}